public static CodecManager <T, D, E> getInstance() { if (instance == null) { instance = new CodecManager <T, D, E>(); } return(instance); }
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); }
private GameNetwork() { msgProcesses = new Dictionary <uint, MsgProcessHandler>(); codecMgr = CodecManager <PBMsg, DecodeHandler <PBMsg>, EncodeHandler <PBMsg> > .getInstance(); }