Exemple #1
0
        static void TestProtoSerializer()
        {
            ProtoSerializer serializer = new ProtoSerializer();

            serializer.LoadProtoNum(typeof(Message.ProtoNumTest));
            LoginRequest msg = new LoginRequest();

            msg.SessionID = "hello";
            byte[] data = serializer.Serialize(msg);

            var deMsg = serializer.Deserialize(data);
        }
Exemple #2
0
        private void InitForClient()
        {
            serverForClient = new ServerNetworkManager();
            var server = new Plugins.Network.WebSocketServer();

            server.Setup("0.0.0.0", 8730);
            var serializer = new Plugins.ProtoSerializer();

            serializer.getTypeFunc = (name) => { return(Type.GetType(name)); };
            serializer.LoadProtoNum(typeof(Message.ProtoNum));
            serverForClient.Init(server, serializer);
            Debug.LogInfo("初始化网络监听(客户端) [{0}]", server.address);
        }
Exemple #3
0
        private void InitMainServer()
        {
            main = new ClientNetworkMangerEx();
            var socket = new Plugins.Network.WebSocketClient();

            socket.Setup("47.100.28.149", 8730);
            var serializer = new Plugins.ProtoSerializer();

            serializer.getTypeFunc = (name) => { return(Type.GetType(name)); };
            serializer.LoadProtoNum(typeof(Message.ProtoNum));
            main.Init(socket, serializer);
            Debug.Log("初始化网络连接(主服) [{0}]".FormatStr(socket.address));
        }
Exemple #4
0
        private void InitForClient()
        {
            forClient = new ServerNetworkManager();
            var listener = new Plugins.Network.WebSocketServer();

            listener.Setup("0.0.0.0", NetConfig.LISTENER_PORT);
            var serializer = new Plugins.ProtoSerializer();

            serializer.getTypeFunc = (name) => { return(Type.GetType(name)); };
            serializer.LoadProtoNum(typeof(Message.ProtoNum));
            forClient.Init(listener, serializer);
            Debug.LogInfo("初始化网络监听(客户端) [{0}]".FormatStr(listener.address));
        }
Exemple #5
0
        private void InitForServer()
        {
            forServer = new ClientNetworkManager();
            var socket = new Plugins.Network.WebSocketClient();

            socket.Setup(NetConfig.SERVER_IP, NetConfig.SERVER_PORT);
            var serializer = new Plugins.ProtoSerializer();

            serializer.getTypeFunc = (name) => { return(Type.GetType(name)); };
            serializer.LoadProtoNum(typeof(Message.ProtoNum));
            forServer.Init(socket, serializer);
            Debug.LogInfo("初始化网络连接(主服) [{0}]".FormatStr(socket.address));
        }