public bool ExecuteHandler(IMsg requestInfo, ISocketSession session) { foreach (var s in session.GetAllSessionId()) { session.SendAsync(s, requestInfo.Data, requestInfo.RemoteIpEndPoint); } return true; }
public bool ExecuteHandler(IMsg requestInfo, ISocketSession session) { byte[] b= new byte[2048]; for(int i=0;i< 2048; i++) { b[i] = 127; } session.SendAsync(requestInfo.Data, requestInfo.RemoteIpEndPoint); return true; }
public bool ProcessFilter(ref IMsg requestMsg) { byte[] dest = ASCIIEncoding.ASCII.GetBytes(Convert.ToBase64String(requestMsg.Data)); requestMsg.Data = dest; return true; }
public bool ProcessFilter(ref IMsg requestMsg) { if (requestMsg != null) { byte[] mark = ASCIIEncoding.ASCII.GetBytes("-From Aton Srv."); byte[] dest = new byte[requestMsg.Data.Length + mark.Length]; Array.Copy(requestMsg.Data, 0, dest, 0, requestMsg.Data.Length); Array.Copy(mark, 0, dest, requestMsg.Data.Length, mark.Length); requestMsg.Data = dest; } return true; }
/// <summary> /// 协议解析处理 /// </summary> /// <param name="buffer">缓存</param> /// <param name="offset">偏移量</param> /// <param name="length">长度</param> /// <param name="request">解析后对象</param> /// <returns>已使用字节数</returns> public int ProtocolProcess(byte[] buffer, int offset, int length, out IMsg requestInfo) { int usedBytes = 0; FixSizeMessage msg = new FixSizeMessage(FixSize); if (length >= FixSize) { Array.Copy(buffer, offset, msg.Data, 0, FixSize); usedBytes = FixSize; } requestInfo = msg; return usedBytes; }
/// <summary> /// 协议解析处理 /// </summary> /// <param name="buffer">缓存</param> /// <param name="offset">偏移量</param> /// <param name="length">长度</param> /// <param name="request">解析后对象</param> /// <returns>已使用字节数</returns> public int ProtocolProcess(byte[] buffer, int offset, int length, out IMsg requestInfo) { int usedBytes = 0; TlvcMessage msg = new TlvcMessage(); if (length > 8) { int tag = BitConverter.ToInt32(buffer,offset); int len= BitConverter.ToInt32(buffer,offset+4); if (msg.Length >= length) { msg.Tag = tag; msg.Length = len; msg.Data = new byte[msg.Length]; Array.Copy(buffer, offset+8, msg.Data, 0, msg.Length); msg.Checksum = BitConverter.ToInt64(buffer,offset+8+msg.Length); usedBytes = msg.Length + 16; } } requestInfo = msg; return usedBytes; }
public abstract int ProtocolProcess(byte[] buffer, int offset, int length, out IMsg requestInfo);