Пример #1
0
 public static CodecManager <T, D, E> getInstance()
 {
     if (instance == null)
     {
         instance = new CodecManager <T, D, E>();
     }
     return(instance);
 }
Пример #2
0
        public bool send <T>(T msg) where T : PBMsg
        {
            if (msg == null || this.state != State.Connected)
            {
                Log.Logger.warn(Log.Module.Network, "send msg:" + msg.GetType() + " failed, for msg == null or no connection");
                return(false);
            }
            PBNetMessage t = msgPool.rent();

            byte[] data = codecMgr.encode(typeof(T), msg);
            //byte[] data = Packet.encodeHttp(
            t.setID(CodecManager <PBMsg, DecodeHandler <PBMsg>, EncodeHandler <PBMsg> > .getHashID(typeof(T)));
            t.setData(data);
            t.setName(typeof(T).Name);
            lock (sendQueue)
            {
                sendQueue.Enqueue(t);
            }
            return(true);
        }
Пример #3
0
 private GameNetwork()
 {
     msgProcesses = new Dictionary <uint, MsgProcessHandler>();
     codecMgr     = CodecManager <PBMsg, DecodeHandler <PBMsg>, EncodeHandler <PBMsg> > .getInstance();
 }