예제 #1
0
    public RequestPlayers requestPlayers()
    {
        RequestPlayers request = new RequestPlayers();

        request.send();
        return(request);
    }
예제 #2
0
        static void Main(string[] args)
        {
            server = new RPCServer(new TestServer(), new PackageTranslator(new ProtocolCenter()));
            ProtocolCenter.RegisterGlobalMessageHandler(globalHandler);
            ProtocolCenter.RegisterMessageHandler(MessageType.RequestSendString, doRequestSendString);
            ProtocolCenter.RegisterMessageHandler(MessageType.RequestPlayers, doRequestPlayers);
            RequestSendString.RegisterHandler(onRequestSendString);
            RequestPlayers.RegisterHandler(onRequestPlayers);
            server.StartListen(7666);

            Console.ReadLine();
        }
예제 #3
0
        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);
                }

            }


        }
예제 #4
0
 static void onRequestPlayers(RequestPlayers vo)
 {
     Console.WriteLine("onRequestPlayers " + vo.customData);
 }
예제 #5
0
 static void onRequestPlayers(RequestPlayers vo)
 {
     Console.WriteLine("onRequestPlayers " + vo.customData);
 }