コード例 #1
0
ファイル: Nexus.cs プロジェクト: szopenfx/code
        /// <summary>
        /// Send an invitation for a game of chess to a peer
        /// </summary>
        /// <param name="UserIndex">Index of the user to be invited</param>
        public void InviteForChess(int UserIndex)
        {
            Console.WriteLine("Nexus.InviteForChess(" + UserIndex.ToString() + ")");

            // get remote IP address and a local port
            IPAddress PeerIP = _Peers.GetPeer(UserIndex).IPAddr;
            int LocalPort = GetLowestChessListenPort();

            // start chess server
            ChessProtocol cp = new ChessProtocol(LocalPort, this);

            // send invitation
            ProtocolWriter pw = new ProtocolWriter(PeerIP, Configuration.ProtocolPort());
            pw.InitGame(Configuration.Username(), LocalPort);
        }
コード例 #2
0
ファイル: ChessGame.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Create new chess game object
 /// </summary>
 public ChessGame(ChessProtocol Protocol, PlayerColor MyColor)
 {
     _ChessProtocol = Protocol;
     _MyColor = MyColor;
     _MoveChecker = new MoveChecker(this);
 }
コード例 #3
0
ファイル: Nexus.cs プロジェクト: szopenfx/code
        /// <summary>
        /// Accept the chess invitation
        /// </summary>
        /// <param name="UserName">Username</param>
        /// <param name="Port">Port</param>
        public void AcceptChessGame(string UserName, int Port)
        {
            Console.WriteLine("Nexus.AcceptChessGame(" + UserName + "," + Port.ToString() + ")");

            // get peer's IP + protocol port
            IPAddress IPAddr = _Peers.GetPeer(UserName).IPAddr;
            int RemotePort = Configuration.ProtocolPort();

            // send acceptance message
            ProtocolWriter pw = new ProtocolWriter(IPAddr, RemotePort);
            pw.AcceptGame(Configuration.Username(), Port);

            // connect to chess server
            ChessProtocol cp = new ChessProtocol(IPAddr, Port);
        }