Пример #1
0
 public void Connect(IPEndPoint endPoint)
 {
     if (Client != null && Client.Connected)
         throw new InvalidOperationException("Already connected to a server!");
     EndPoint = endPoint;
     Client = new TcpClient();
     Client.Connect(EndPoint);
     NetworkStream = Client.GetStream();
     Stream = new MinecraftStream(new BufferedStream(NetworkStream));
     NetworkWorkerThread = new Thread(NetworkWorker);
     NetworkWorkerThread.Start();
     var handshake = new HandshakePacket(PacketReader.ProtocolVersion, Session.SelectedProfile.Name,
         EndPoint.Address.ToString(), EndPoint.Port);
     SendPacket(handshake);
 }
Пример #2
0
 public void Connect(IPEndPoint endPoint)
 {
     if (Client != null && Client.Connected)
         throw new InvalidOperationException("Already connected to a server!");
     EndPoint = endPoint;
     Client = new TcpClient();
     Client.Connect(EndPoint);
     NetworkStream = Client.GetStream();
     NetworkManager = new NetworkManager(NetworkStream);
     NetworkingReset = new ManualResetEvent(true);
     NetworkWorkerThread = new Thread(NetworkWorker);
     NetworkWorkerThread.Start();
     var handshake = new HandshakePacket(NetworkManager.ProtocolVersion, 
         EndPoint.Address.ToString(), (ushort)EndPoint.Port, NetworkMode.Login);
     SendPacket(handshake);
     var login = new LoginStartPacket(Session.SelectedProfile.Name);
     SendPacket(login);
 }