private static unsafe int OnMessage(UOMessage msg, int arg1, int arg2, int arg3, byte *data) { try { switch (msg) { case UOMessage.Ready: Ready = true; hooks.Send(UOMessage.ConnectionInfo, (int)ServerIP, ServerPort); hooks.Send(UOMessage.GameSize, Width, Height); OnInit(); break; case UOMessage.Connected: Connected.Raise(); break; case UOMessage.Disconnecting: Disconnecting.Raise(); break; case UOMessage.Closing: Closing.Raise(); break; case UOMessage.Focus: FocusChanged.Raise(arg1 != 0); break; case UOMessage.Visibility: VisibilityChanged.Raise(arg1 != 0); break; case UOMessage.KeyDown: UOKeyEventArgs keyArgs = new UOKeyEventArgs(arg1, arg2); KeyDown.Raise(keyArgs); if (keyArgs.Filter) { return(1); } break; case UOMessage.PacketToClient: Packet toClient = new Packet(data, arg1); PacketToClient.Raise(toClient); if (toClient.Filter) { return(1); } if (toClient.Changed) { return(2); } break; case UOMessage.PacketToServer: Packet toServer = new Packet(data, arg1); PacketToServer.Raise(toServer); if (toServer.Filter) { return(1); } if (toServer.Changed) { return(2); } break; } } catch (Exception ex) { OnException(ex); } return(0); }