static public void Register(PackageTranslator target) { target.RegisterMessage(Protocol.sendLogin, Create_sendLoginVO); target.RegisterMessage(Protocol.testCommonStruct, Create_testCommonStructVO); target.RegisterMessage(Protocol.sendString, Create_sendStringVO); }
public void start() { translator = new PackageTranslator(new ProtocolCenter()); connection = new SocketConnection("127.0.0.1", 7666); client = new RPCClient(connection, translator); ProtocolCenter.RegisterMessageHandler(MessageType.ResponseSendString, ResponseSendString); //client.RegisterMessageHandler(MessageType.ResponsePlayers, ResponsePlayers); ResponsePlayers.RegisterHandler(onResponsePlayers); ProtocolCenter.RegisterGlobalMessageHandler(globalMessageHandler); client.OnConnectSuccess += OnConnectSuccess; client.OnConnectFail += OnConnectFail; client.OnConnectClose += OnConnectClose; client.Connect(); /* connection.OnConnectSuccess += OnConnectSuccess; connection.OnData += OnData; connection.OnConnectClose += OnConnectClose; connection.Connect(); */ while (true) { var input = Console.ReadLine(); if (input.IndexOf("2") >= 0) { var msg = new RequestPlayers(); client.Call(msg); } else { var sendStr = new RequestSendString(); sendStr.content = input; client.Call(sendStr); } } }
static public PackageTranslator GetTranslator() { var translator = new PackageTranslator(); Register(translator); return translator; }
public RPCServer(TestServer server, PackageTranslator translator) { this.server = server; this.translator = translator; server.OnData += OnData; }
public RPCClient(BaseConnection connection, PackageTranslator packager) { this.connection = connection; this.packager = packager; }