Exemplo n.º 1
0
 internal void OnSomeOneDisconnected(Interface5 interface5_0, DisconnectedType disconnectedType_0)
 {
     lock (interface5_0)
     {
         if (!interface5_0.imethod_6())
         {
             interface5_0.imethod_7(true);
             interface5_0.GetStream().Close();
             interface5_0.GetStream().Dispose();
             this.class142_0.method_7(interface5_0.GetIPEndPoint());
             this.eventSafeTrigger_0.Action <IPEndPoint, DisconnectedType>("SomeOneDisconnected", this.SomeOneDisconnected, interface5_0.GetIPEndPoint(), disconnectedType_0);
         }
     }
 }
Exemplo n.º 2
0
    public bool SendMessageToClient(IPEndPoint ipendPoint_0, IMessageHandler interface37_0, ActionTypeOnChannelIsBusy actionTypeOnChannelIsBusy_0)
    {
        if ((interface37_0 == null) || this.bool_0)
        {
            return(false);
        }
        Interface5 interface2 = this.class142_0.method_9(ipendPoint_0);

        if (interface2 == null)
        {
            return(false);
        }
        byte[] buffer = interface37_0.ToStream();
        if (buffer.Length > this.int_1)
        {
            throw new Exception(string.Format("Size of message to be sent overflow! Message type is {0}.", interface37_0.Header.MessageType));
        }
        if (interface2.ChannelIsBusy && (actionTypeOnChannelIsBusy_0 == ActionTypeOnChannelIsBusy.Discard))
        {
            return(false);
        }
        if ((this.int_5 > 0) && (interface2.imethod_19() >= this.int_5))
        {
            this.OnSomeOneDisconnected(interface2, DisconnectedType.ChannelCacheOverflow);
            return(false);
        }
        bool flag2 = false;

        try
        {
            interface2.imethod_16();
            interface2.imethod_11(ref buffer);
            interface2.GetStream().Write(buffer, 0, buffer.Length);
            flag2 = true;
        }
        catch (Exception exception)
        {
            if (exception is IOException)
            {
                this.OnSomeOneDisconnected(interface2, DisconnectedType.NetworkInterrupted);
            }
            else
            {
                this.emptyAgileLogger_0.Log(exception, "CJFramework.Engine.Tcp.Server.BaseTcpEngine.SendMessageToClient", ErrorLevel.High);
            }
        }
        finally
        {
            interface2.imethod_17();
        }
        if (flag2)
        {
            this.eventSafeTrigger_0.Action <IPEndPoint, IMessageHandler>("MessageSent", this.MessageReceived, interface2.GetIPEndPoint(), interface37_0);
        }
        return(flag2);
    }
Exemplo n.º 3
0
 internal override void ReceiveFirstMessage(Interface5 interface5_0)
 {
     try
     {
         Class7 class2 = (Class7)interface5_0;
         interface5_0.GetStream().BeginRead(class2.method_4(), 0, this.interface46_0.imethod_9(), new AsyncCallback(this.ServeOverLap), interface5_0);
     }
     catch (Exception exception)
     {
         if ((exception is IOException) || (exception is ObjectDisposedException))
         {
             base.OnSomeOneDisconnected(interface5_0, DisconnectedType.NetworkInterrupted);
         }
         else
         {
             base.emptyAgileLogger_0.Log(exception, "CJFramework.Engine.Tcp.Server.StreamTcpEngine.ReceiveFirstMessage", ErrorLevel.High);
         }
     }
 }
Exemplo n.º 4
0
    public bool PostMessageToClient(IPEndPoint ipendPoint_0, IMessageHandler interface37_0, ActionTypeOnChannelIsBusy actionTypeOnChannelIsBusy_0)
    {
        if ((interface37_0 == null) || this.bool_0)
        {
            return(false);
        }
        Interface5 interface2 = this.class142_0.method_9(ipendPoint_0);

        if (interface2 == null)
        {
            return(false);
        }
        byte[] buffer = interface37_0.ToStream();
        if (buffer.Length > this.int_1)
        {
            throw new Exception(string.Format("Size of message to be post overflow! Message type is {0}.", interface37_0.Header.MessageType));
        }
        if (interface2.ChannelIsBusy && (actionTypeOnChannelIsBusy_0 == ActionTypeOnChannelIsBusy.Discard))
        {
            return(false);
        }
        try
        {
            interface2.imethod_14();
            interface2.imethod_11(ref buffer);
            interface2.GetStream().BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(this.OnPostMessageCallback), new Class37(interface2, interface37_0));
            return(true);
        }
        catch (Exception exception)
        {
            interface2.imethod_15();
            if (((exception is IOException) || (exception is ObjectDisposedException)) || (exception is InvalidOperationException))
            {
                this.OnSomeOneDisconnected(interface2, DisconnectedType.NetworkInterrupted);
            }
            else
            {
                this.emptyAgileLogger_0.Log(exception, "CJFramework.Engine.Tcp.Server.BaseTcpEngine.PostMessageToClient", ErrorLevel.Standard);
            }
            return(false);
        }
    }