public static bool OnSendBytes(ServerSock socket, byte[] buffer, int offset, int count) { if (NetHooks.SendBytes == null) { return false; } HandledEventArgs handledEventArgs = new HandledEventArgs(); NetHooks.SendBytes(socket, buffer, offset, count, handledEventArgs); return handledEventArgs.Handled; }
public static void SendBytes(ServerSock sock, byte[] buffer, int offset, int count, AsyncCallback callback, object state) { if (NetHooks.OnSendBytes(sock, buffer, offset, count)) { return; } if (Main.runningMono) sock.networkStream.Write(buffer, offset, count); else sock.networkStream.BeginWrite(buffer, offset, count, callback, state); }
/// <summary> /// Send bytes to client using packetbuffering if available /// </summary> /// <param name="client">socket to send to</param> /// <param name="bytes">bytes to send</param> /// <returns>False on exception</returns> public static bool SendBytes(ServerSock client, byte[] bytes) { if (PacketBuffer != null) { PacketBuffer.BufferBytes(client, bytes); return true; } return SendBytesBufferless(client,bytes); }
/// <summary> /// Send bytes to a client ignoring the packet buffer /// </summary> /// <param name="client">socket to send to</param> /// <param name="bytes">bytes to send</param> /// <returns>False on exception</returns> public static bool SendBytesBufferless(ServerSock client, byte[] bytes) { try { if (client.tcpClient.Connected) client.networkStream.Write(bytes, 0, bytes.Length); return true; } catch (Exception ex) { Log.Warn("This is a normal exception"); Log.Warn(ex.ToString()); } return false; }
public static void OnSocketReset(ServerSock socket) { if (ServerHooks.SocketReset != null) { ServerHooks.SocketReset(socket); } }