コード例 #1
0
ファイル: Client.cs プロジェクト: ngovi2298/uit-war
 public new bool Show()
 {
     byte[] dataReceived = new byte[1024];
     try
     {
         int recv = client.Receive(dataReceived);
         if (recv > 0)
         {
             int[] location = (int[])Both.DeserializeData(dataReceived);
             //set server's archer location
             this.archer_left.Location = new Point(location[0], location[1]);
             return(true);
         }
         //else
         //{
         //    Console.WriteLine("Connection lost!!! no mess to show");
         //    return false;
         //}
     }
     catch
     {
         //Console.WriteLine("Connection lost!!!catch");
         return(false);
     }
     return(false);
 }
コード例 #2
0
ファイル: SocketManager.cs プロジェクト: ngovi2298/uit-war
        public static string GetLocalIPv4_v2()
        {
            string ip = Both.GetLocalIPv4(System.Net.NetworkInformation.NetworkInterfaceType.Wireless80211);

            if (String.IsNullOrEmpty(ip))
            {
                ip = Both.GetLocalIPv4(System.Net.NetworkInformation.NetworkInterfaceType.Ethernet);
            }
            return(ip);
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: ngovi2298/uit-war
 public bool Send(int x, int y)
 {
     int[]  location   = { x, y };
     byte[] dataToSend = Both.SerializeData(location);
     try
     {
         client.Send(dataToSend);
         return(true);
     }
     catch (Exception)
     {
         //Console.WriteLine("Can not send message");
         return(false);
     }
 }