Beispiel #1
0
 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;
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 /// <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;
 }
Beispiel #5
0
 public static void OnSocketReset(ServerSock socket)
 {
     if (ServerHooks.SocketReset != null)
     {
         ServerHooks.SocketReset(socket);
     }
 }