Example #1
0
        /// <summary>
        /// Client is closing socket.
        /// </summary>
        public static void OnCloseSocket(long s)
        {
            if (!Core.IsClientThread)
            {
                Trace.WriteLine("Warning: Closing socket from different thread.", "Communication");
            }

            bool callDisconnected = false;

            lock (SyncRoot) {
                Trace.WriteLine(String.Format("Closing socket {0}.", s), "Communication");

                if (ultimaSocket != null && ultimaSocket.Socket == s)
                {
                    // Client is disconnected.
                    ultimaSocket     = null;
                    callDisconnected = !redirecting;
                }
            }

            // Mimo sync kontext
            if (callDisconnected)
            {
                Core.OnDisconnected(EventArgs.Empty);
            }
        }
Example #2
0
        static void Core_ShuttingDown(object sender, EventArgs e)
        {
            if (ultimaSocket != null)
            {
                Trace.WriteLine(String.Format("Warning: Exiting with opened socket {0}. Closing..", ultimaSocket.Socket), "Communication");

                WinSock.closesocket(ultimaSocket.Socket);
                ultimaSocket = null;
            }
        }
Example #3
0
        /// <summary>
        /// Client is sending data.
        /// </summary>
        public static int OnSend(long s, byte[] buff, int len, int flags)
        {
            CheckThread();

            lock (SyncRoot) {
                if (ultimaSocket != null && ultimaSocket.Socket == s)
                {
                    if (redirecting)
                    {
                        Trace.WriteLine("Warning: Client is reusing login socket as game socket.", "Communication");
                        ultimaSocket = new GameSocket(s, ultimaSocket.Address, ultimaSocket.Port, loginSeed);
                        redirecting  = false;
                    }

                    return(ultimaSocket.Send(s, buff, len, flags));
                }
                else
                {
                    return(WinSock.send(s, buff, len, flags));
                }
            }
        }
Example #4
0
        /// <summary>
        /// Client is connecting to somewhere.
        /// </summary>
        public static void OnConnect(long s, uint address, int port)
        {
            CheckThread();

            lock (SyncRoot) {
                byte[] ip = ByteConverter.LittleEndian.GetBytes(address);
                Trace.WriteLine(String.Format("Connecting to {1}.{2}.{3}.{4},{5} on socket {0}.", s, ip[0], ip[1], ip[2], ip[3], port), "Communication");

                if (port != 28888) // Translation server? (copied from UOInjection)
                {
                    if (!redirecting)
                    {
                        ultimaSocket = new LoginSocket(s, address, port);
                        redirecting  = false;
                    }
                    else
                    {
                        ultimaSocket = new GameSocket(s, address, port);
                        redirecting  = false;
                    }
                }
            }
        }
        static void Core_ShuttingDown(object sender, EventArgs e)
        {
            if (ultimaSocket != null) {
                Trace.WriteLine(String.Format("Warning: Exiting with opened socket {0}. Closing..", ultimaSocket.Socket), "Communication");

                WinSock.closesocket(ultimaSocket.Socket);
                ultimaSocket = null;
            }
        }
        /// <summary>
        /// Client is sending data.
        /// </summary>
        public static int OnSend(long s, byte[] buff, int len, int flags)
        {
            CheckThread();

            lock (SyncRoot) {
                if (ultimaSocket != null && ultimaSocket.Socket == s) {
                    if (redirecting) {
                        Trace.WriteLine("Warning: Client is reusing login socket as game socket.", "Communication");
                        ultimaSocket = new GameSocket(s, ultimaSocket.Address, ultimaSocket.Port, loginSeed);
                        redirecting = false;
                    }

                    return ultimaSocket.Send(s, buff, len, flags);
                }
                else {
                    return WinSock.send(s, buff, len, flags);
                }
            }
        }
        /// <summary>
        /// Client is connecting to somewhere.
        /// </summary>
        public static void OnConnect(long s, uint address, int port)
        {
            CheckThread();

            lock (SyncRoot) {
                byte[] ip = ByteConverter.LittleEndian.GetBytes(address);
                Trace.WriteLine(String.Format("Connecting to {1}.{2}.{3}.{4},{5} on socket {0}.", s, ip[0], ip[1], ip[2], ip[3], port), "Communication");

                if (port != 28888) // Translation server? (copied from UOInjection)
                {
                    if (!redirecting) {
                        ultimaSocket = new LoginSocket(s, address, port);
                        redirecting = false;
                    }
                    else {
                        ultimaSocket = new GameSocket(s, address, port);
                        redirecting = false;
                    }
                }
            }
        }
        /// <summary>
        /// Client is closing socket.
        /// </summary>
        public static void OnCloseSocket(long s)
        {
            if (!Core.IsClientThread)
                Trace.WriteLine("Warning: Closing socket from different thread.", "Communication");

            bool callDisconnected = false;

            lock (SyncRoot) {
                Trace.WriteLine(String.Format("Closing socket {0}.", s), "Communication");

                if (ultimaSocket != null && ultimaSocket.Socket == s) {
                    // Client is disconnected.
                    ultimaSocket = null;
                    callDisconnected = !redirecting;
                }
            }

            // Mimo sync kontext
            if (callDisconnected) {
                Core.OnDisconnected(EventArgs.Empty);
            }
        }
Example #9
0
 internal SocketException(string message, UltimaSocket socket, byte[] data, Exception inner)
     : base(message, inner)
 {
     socketDump = socket.Dump();
     socketDump += "Current data:\n" + PacketLogging.BuildString(data);
 }
Example #10
0
 internal SocketException(string message, UltimaSocket socket, Exception inner)
     : base(message, inner)
 {
     socketDump = socket.Dump();
 }
Example #11
0
 internal SocketException(UltimaSocket socket)
 {
     socketDump = socket.Dump();
 }
Example #12
0
 internal SocketException(string message, UltimaSocket socket, byte[] data, Exception inner)
     : base(message, inner)
 {
     socketDump  = socket.Dump();
     socketDump += "Current data:\n" + PacketLogging.BuildString(data);
 }
Example #13
0
 internal SocketException(string message, UltimaSocket socket, Exception inner)
     : base(message, inner)
 {
     socketDump = socket.Dump();
 }
Example #14
0
 internal SocketException(UltimaSocket socket)
 {
     socketDump = socket.Dump();
 }