/// <summary> /// Use underline socket to send protocol message async. /// </summary> /// <param name="vMessage">The protocol message to be sended.</param> public void SendMessage(System.Object vMsg) { if (State != ConnectionState.Established) { Debug.WriteLine(String.Format("SendMessage Error:in State {0}", State)); return; } if (vMsg == null) { Debug.WriteLine(String.Format("SendMessage Error:vMsg is null")); return; } ArraySegment <Byte> sndBuf = ProtoHelper.EncodeMessage(vMsg, Provider); SocketAsyncEventArgs sendEventArgs = new SocketAsyncEventArgs(); sendEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(OnCompletedForSend); sendEventArgs.SetBuffer(sndBuf.Array, sndBuf.Offset, sndBuf.Count); Debug.WriteLine(string.Format("SendMessage Send {0}", vMsg.GetType().Name)); if (!ConnSocket.SendAsync(sendEventArgs)) { OnCompletedForSendImpl(sendEventArgs); sendEventArgs.Dispose(); } }
// Token: 0x06006AFA RID: 27386 RVA: 0x001E034C File Offset: 0x001DE54C private void WriteMsg2RecvCache(object msg) { object recvCache = this.m_recvCache; lock (recvCache) { ArraySegment <byte> arraySegment = ProtoHelper.EncodeMessage(msg, this.m_provider); this.m_recvCache.Write(arraySegment.Array, arraySegment.Count); } }
// Token: 0x06006AF5 RID: 27381 RVA: 0x001DFFEC File Offset: 0x001DE1EC public void SendMessage(object msg) { if (this.State != ConnectionState.Established) { global::Debug.WriteLine(string.Format("SendMessage Error:in State {0}", this.State)); return; } if (msg == null) { global::Debug.WriteLine("SendMessage Error:msg is null"); return; } ArraySegment <byte> arraySegment = ProtoHelper.EncodeMessage(msg, this.m_provider); SocketAsyncEventArgs socketAsyncEventArgs = new SocketAsyncEventArgs(); socketAsyncEventArgs.Completed += this.OnCompletedForSend; socketAsyncEventArgs.SetBuffer(arraySegment.Array, arraySegment.Offset, arraySegment.Count); global::Debug.WriteLine(string.Format("SendMessage Send {0}", msg.GetType().Name)); if (!this.m_socket.SendAsync(socketAsyncEventArgs)) { this.OnCompletedForSendImpl(socketAsyncEventArgs); socketAsyncEventArgs.Dispose(); } }