public IMsgHeader GenerateHeader(string type) { IMsgHeader header = new DefaultMsgHeader(); this.Header = header; return(header); }
public IMsgHeader GenerateHeader(bool encrypted, bool compressed) { IMsgHeader header = new DefaultMsgHeader(encrypted, compressed); this.Header = header; return(header); }
/// <summary> /// Builds a message header. /// </summary> public IMsgHeader BuildHeader() { IMsgHeader header = _message.Header; header.Sender = Sender; return(header); }
public void OnDataWrite(ByteBuffer message) { TcpNetWorkClinet net = network as TcpNetWorkClinet; IMsgHeader header = protocol.GenerateHeader(false, false); net.ThreadManager.EnqueueSend(WriteBinaryData, header, message, false); }
public override object OnGenerateMsg(IMsgHeader header, ByteBuffer data) { DefaultMsgHeader dheader = header as DefaultMsgHeader; var msg = DeserializePbMsg(dheader.MsgType, data); return(msg); }
public override void HandleMesage(IMsgHeader header, object message) { DefaultMsgHeader dheader = header as DefaultMsgHeader; RequestProtoBufDelegate cb = this.Callbacks[dheader.MsgType]; if (cb != null) { cb(network, message); } Debug.WriteLine("call Protobuf controller handle message"); }
private void ProcessOutItem(Hashtable item) { object obj = item["callback"]; WriteBinaryDataDelegate writeBinaryDataDelegate = obj as WriteBinaryDataDelegate; if (writeBinaryDataDelegate != null) { ByteBuffer binData = item["data"] as ByteBuffer; IMsgHeader header = item["header"] as IMsgHeader; bool udp = (bool)item["udp"]; writeBinaryDataDelegate(header, binData, udp); } }
public void EnqueueSend(WriteBinaryDataDelegate callback, IMsgHeader header, ByteBuffer data, bool udp) { Hashtable hashtable = new Hashtable(); hashtable["callback"] = callback; hashtable["header"] = header; hashtable["data"] = data; hashtable["udp"] = udp; lock (outQueueLocker) { outThreadQueue.Enqueue(hashtable); outHasQueuedItems = true; } }
private void WriteBinaryData(IMsgHeader header, ByteBuffer binData, bool udp = false) { if (header.Compressed) { // TODO } if (header.Encrypted) { // TODO } else if (network.Socket.IsConnected) { WriteTCP(binData); } }
private void HandleNetWorkPacket(ByteBuffer data) { try { IMsgHeader header = protocol.GenerateHeader(protocol.PayLoadType); header.FromBinary(data); // TODO ���� // TODO ��ѹ var message = CenerateMsg(protocol.Header, data); HandleMesage(header, message); } catch (Exception ex) { Debug.WriteLine("net io handler handle packet error !"); } }
public abstract void HandleMesage(IMsgHeader header, object message);
private void HandleMesage(IMsgHeader header, object message) { network.Controller.HandleMesage(header, message); }
private object CenerateMsg(IMsgHeader header, ByteBuffer data) { var mesage = protocol.Codec.OnGenerateMsg(protocol.Header, data); return(mesage); }
public virtual object OnGenerateMsg(IMsgHeader header, ByteBuffer data) { return(null); }
public override void HandleMesage(IMsgHeader header, object message) { Debug.WriteLine("Call DefaultController HandleMesage"); }