public void SendPacket(StreamBuffer buffer, PacketCriterion criterion, EventHandler_Receive dispatcher, Action<StreamBuffer> onSent = null) { if (criterion == null || dispatcher == null) throw new AegisException(AegisResult.InvalidArgument, "The argument criterion and dispatcher cannot be null."); try { lock (_session) { _responseSelector.Add(criterion, dispatcher); if (_session.Socket != null) { // ReadIndex가 OnSocket_Send에서 사용되므로 ReadIndex를 초기화해야 한다. buffer.ResetReadIndex(); if (onSent == null) _session.Socket.BeginSend(buffer.Buffer, 0, buffer.WrittenBytes, SocketFlags.None, OnSocket_Send, null); else _session.Socket.BeginSend(buffer.Buffer, 0, buffer.WrittenBytes, SocketFlags.None, OnSocket_Send, new NetworkSendToken(buffer, onSent)); } } } catch (SocketException) { } catch (Exception e) { Logger.Write(LogType.Err, 1, e.ToString()); } }
public void SendPacket(StreamBuffer buffer, PacketCriterion criterion, EventHandler_Receive dispatcher, Action<StreamBuffer> onSent = null) { if (criterion == null || dispatcher == null) throw new AegisException(AegisResult.InvalidArgument, "The argument criterion and dispatcher cannot be null."); try { lock (_session) { if (_session.Socket == null) return; // ReadIndex가 OnSocket_Send에서 사용되므로 ReadIndex를 초기화해야 한다. buffer.ResetReadIndex(); SocketAsyncEventArgs saea = new SocketAsyncEventArgs(); saea.Completed += OnComplete_Send; saea.SetBuffer(buffer.Buffer, 0, buffer.WrittenBytes); if (onSent != null) saea.UserToken = new NetworkSendToken(buffer, onSent); _responseSelector.Add(criterion, dispatcher); if (_session.Socket.SendAsync(saea) == false) OnComplete_Receive(null, saea); } } catch (SocketException) { } catch (Exception e) { Logger.Write(LogType.Err, 1, e.ToString()); } }
public void SendPacket(StreamBuffer buffer, Action<StreamBuffer> onSent = null) { try { lock (_session) { if (_session.Socket != null) { // ReadIndex가 OnSocket_Send에서 사용되므로 ReadIndex를 초기화해야 한다. buffer.ResetReadIndex(); if (onSent == null) _session.Socket.BeginSend(buffer.Buffer, 0, buffer.WrittenBytes, SocketFlags.None, OnSocket_Send, null); else _session.Socket.BeginSend(buffer.Buffer, 0, buffer.WrittenBytes, SocketFlags.None, OnSocket_Send, new NetworkSendToken(buffer, onSent)); } } } catch (SocketException) { } catch (Exception e) { Logger.Write(LogType.Err, 1, e.ToString()); } }
public void SendPacket(StreamBuffer buffer, Action<StreamBuffer> onSent = null) { try { lock (_session) { if (_session.Socket == null) return; // ReadIndex가 OnSocket_Send에서 사용되므로 ReadIndex를 초기화해야 한다. buffer.ResetReadIndex(); SocketAsyncEventArgs saea = new SocketAsyncEventArgs(); saea.Completed += OnComplete_Send; saea.SetBuffer(buffer.Buffer, 0, buffer.WrittenBytes); if (onSent != null) saea.UserToken = new NetworkSendToken(buffer, onSent); if (_session.Socket.SendAsync(saea) == false) OnComplete_Receive(null, saea); } } catch (SocketException) { } catch (Exception e) { Logger.Write(LogType.Err, 1, e.ToString()); } }