/// <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); } }
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 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 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); } }
internal SocketException(string message, UltimaSocket socket, byte[] data, Exception inner) : base(message, inner) { socketDump = socket.Dump(); socketDump += "Current data:\n" + PacketLogging.BuildString(data); }
internal SocketException(string message, UltimaSocket socket, Exception inner) : base(message, inner) { socketDump = socket.Dump(); }
internal SocketException(UltimaSocket socket) { socketDump = socket.Dump(); }