Skip to content

Networking events

Wikiti edited this page Jan 3, 2017 · 3 revisions

As stated before, this library is based on events and event-drive programming. The following events are available in networking.utils.NetworkEvent:

INIT_SUCCESS

  • Server: Server successfully binded to the given ip and port.
  • Client: Client connected to the server successfully.

INIT_FAILURE

  • Server: Server could not bind the given ip and port.
  • Client: Client could not connect to the server.

CONNECTED

  • Server: New client connected.
  • Client: Client connected to the server (after INIT_SUCCESS).

DISCONNECTED

  • Server: Client disconnected (due to an error or voluntarily).
  • Client: Disconnected from the server (kicked or due to an error), which means that the socket is closed (asynchronously).

CLOSED

  • Server: Session closed (called on session.stop() or Network.destroySession(session)).
  • Client: Disconnected from the server (voluntarily) by closing the session (called on session.stop() or Network.destroySession(session)).

MESSAGE_RECEIVED

  • Server: Message recieved from a client.
  • Client: Message recieved from the server.

MESSAGE_SENT

  • Server: Message sent to a client.
  • Client: Message sent to the server.

MESSAGE_SENT_FAILED

  • Server: An error occurred while sending a message to a specific client.
  • Client: An error occurred while sending a message to the server.

MESSAGE_BROADCAST

  • Server: Send message to all clients.
  • Client: Unused.

MESSAGE_BROADCAST_FAILED

  • Server: Something went wrong while sending a broadcast message.
  • Client: Unused.

SERVER_FULL

  • Server: A client tried to connect to the server, which is full.
  • Client: The client tried to connect to a full server.

SECURITY_ERROR

  • Server: Something went wrong while creating a policy file server.
  • Client: Unused.