public ClientSocket(Socket clientSocket, ServerSocket serverSocket) { this.serverSocket = serverSocket; //this.databaseWorker = serverSocket.DatabaseWorker; if (clientSocket.RemoteEndPoint.AddressFamily == AddressFamily.InterNetwork) { isNpc = true; } externalSock = clientSocket; internalSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ip = IPAddress.Parse(((IPEndPoint)this.externalSock.RemoteEndPoint).Address.ToString()).ToString(); serverSocket.Clients.Add(this); internalSock.Connect("127.0.0.1", this.serverSocket.intport); internalSock.SendTimeout = 30000; internalSock.ReceiveTimeout = 30000; externalSock.SendTimeout = 30000; externalSock.ReceiveTimeout = 30000; internalThread = new Thread(new ThreadStart(this.InternalThread)); externalThread = new Thread(new ThreadStart(this.ExternalThread)); pingThread = new Thread(new ThreadStart(this.PingThread)); //internalSock.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); //externalSock.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); internalThread.Start(); externalThread.Start(); pingThread.Start(); this.serverSocket.Tunnel.MinecraftHandler.PlayerJoined += new MinecraftHandler.OnPlayerjoined(MinecraftHandler_PlayerJoined); }
public static void HandleChat(String text, MinecraftHandler mc, String name, ServerSocket serverSocket, ClientSocket client, ref bool flag2) { }
public TcpTunnelServer(MinecraftHandler mc) { minecraftHandler = mc; serverSocket = new ServerSocket(this); }
public void OnServerLoaded(IMinecraftHandler mc, IServer server) { this.server = server as ServerSocket; }
public CommandResult CommandHandlerExternal(String userName, String command, String args,ClientSocket client,ServerSocket server) { if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(command)) { return null; } string username = userName; try { CommandManager helper = CommandManager.GetInstance(this); String commandMatch = EasyGuess.GetMatchedCommand(helper, command); if (String.IsNullOrEmpty(commandMatch)) { return null; } Command c = helper.Items[commandMatch]; if (c != null) { UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); User user = userCollection.GetUserByName(userName); if (user == null) { user = new User(userName); } if (user != null && user.Level.IsCommandInList(commandMatch)) { string arg1 = "", arg2 = "", arg3 = ""; GetArgs(args, out arg1, out arg2, out arg3); c.ClientUser = user; c.RegArg = args; c.Client = client; c.Server = server; c.TriggerPlayer = userName; CommandResult result; if(arg1.Length>0&&arg1[0]=='?') result = c.ExecuteHelp(); else result = c.Execute(arg1, arg2, arg3, userName); return result; } } } catch {} return new CommandResult(); }