private void _adapter_ReceiveCompleted(object sender, SocketHelper.Events.ReceiveEventArgs args) { if (args.ByteLenght >= 4) { int code = BitConverter.ToInt32(args.ReceivedBytes, 0); switch (code) { case MessageCode.StartServer: { GatewayServer.StartServer(); } break; case MessageCode.StopServer: { GatewayServer.StopServer(); } break; case MessageCode.StartRegister: { StringPacket sp = StringPacket.DeserializeObject(args.ReceivedBytes); GatewayServer.StartRegister(sp.Content); } break; case MessageCode.StopRegister: { StringPacket sp = StringPacket.DeserializeObject(args.ReceivedBytes); GatewayServer.StopRegister(sp.Content); } break; case MessageCode.IsServerStarted: { send(new BoolPacket(code, GatewayServer.IsServerStarted())); } break; case MessageCode.IsSuperiorOnline: { StringPacket sp = StringPacket.DeserializeObject(args.ReceivedBytes); send(new BoolPacket(code, GatewayServer.IsSuperOnline(sp.Content))); } break; case MessageCode.ShareDevice: { StringPacket sp = StringPacket.DeserializeObject(args.ReceivedBytes); GatewayServer.ShareToPlatform(sp.Content); } break; } } }