# Server equilavent to clientEvent()?

**URL:** <https://discourse.processing.org/t/server-equilavent-to-clientevent/14265>\
**Category:** Libraries\
**Created:** [September 29, 2019, 8:02am UTC](https://discourse.processing.org/t/server-equilavent-to-clientevent/14265 "2019-09-29T08:02:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brastin](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@Brastin](https://discourse.processing.org/u/Brastin)\
**Post date:** [September 29, 2019, 8:02am UTC](https://discourse.processing.org/t/server-equilavent-to-clientevent/14265/1 "2019-09-29T08:02:01Z")

</div>

I’m trying to make a multiplayer game, and at the start it needs to send map data across from the host to the other players. A lot of examples I’ve seen use two different applications, a client and a server, but I’ve tied it into one program so the person can play or host and play from the same program. Initially I was using write() and readString() to send/recieve data but often some bits of data would get dropped since it was tied to the framerate. I found clientEvent() which runs the code every time the server receives data from the client. I set it up so it appends whatever data it receives to a string and it waits until its received the full message. This works great and after testing for a while it hasn’t dropped anything.

The problem is I can’t find an equivalent method for running code when the server receives data from the client. I could still readString() each frame but it would be slow and unreliable. Does anyone know how I could achieve this?

code snippet from the clientEvent method:

```auto
void clientEvent(Client someClient) {
  println(testmessage);
  testmessage += getDataString();
  if(testmessage.contains("\n")){
    if(testmessage!=null&&testmessage.length()>=2){
      if(testmessage.charAt(0)=='!'){
        consoleUpdate(testmessage.substring(1,testmessage.length()));
      }
    }
    testmessage="";
  }
}

```

Also, I’m aware serverEvent exists but it only runs when a client joins the server, not when a client sends a message.  
Thanks in advance.
