1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Asynchronous data packets

Discussion in 'Development' started by Sergey Dertan, Mar 11, 2019.

  1. Sergey Dertan

    Sergey Dertan Silverfish

    Messages:
    18
    I need to send packets with large strings which make lags, can I do it async?
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    You can't use instances on async tasks, use these tasks to arsort, foreach(scandir("folder with lots of files")), etc. If you are editing some of the strings before you send the packet, then it's possible to make it edit asynchronously. What are you trying to do?
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What packets are you sending? You might want to use a BatchPacket (my knowledge on the protocol is outdated for 2 years, so don't quote me)
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You might want to recheck if that's what makes it lag. It doesn't sound like something that would cause a whole lot of lag on itself, unless of course you do intensive computing to produce the strings.
     
  5. Sergey Dertan

    Sergey Dertan Silverfish

    Messages:
    18
    I need to send large text packets to each player each second(up to 300 symbols), as I know it's taking much time to encode packets so I want to send them async
     
  6. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    So have you checked if it's actually a problem? Don't prematurely optimise.
     
    Muqsit likes this.
  7. Sergey Dertan

    Sergey Dertan Silverfish

    Messages:
    18
    Yes, without this task I have no lags
     
  8. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Yes so perhaps show the code so we can help you find what is actually causing this.
     
  9. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    If you're trying to send a player messages, why use text packets directly and not use the built-in function called sendMessage()?
     
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    One 300-character text packet per second is pretty small. One SetEntityMotionPacket takes uvarint+uvarlong+lfloat*3 = approx. 16 bytes, and it gets sent per entity per tick (I think so), which multiply up to way more than 300B/s. I don't think sending the packet itself is the source of lag.
    BTW make sure you're talking about server-side lag not client-side lag. Does the TPS actually decrease?

    Please show the code of this task that seems to create lag so that we can help find out what's causing the lag.
     
    Sandertv and Muqsit like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.