예제 #1
0
파일: NetHooks.cs 프로젝트: pfchrono/Toaria
 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;
 }
예제 #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);
 }
예제 #3
0
파일: TShock.cs 프로젝트: pfchrono/Toaria
        /// <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);
        }
예제 #4
0
파일: TShock.cs 프로젝트: pfchrono/Toaria
 /// <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;
 }
예제 #5
0
 public static void OnSocketReset(ServerSock socket)
 {
     if (ServerHooks.SocketReset != null)
     {
         ServerHooks.SocketReset(socket);
     }
 }