示例#1
0
 public static void ServerRun(string ip, int port)
 {
     server          = new NetWorkServer(ip, port);
     server.answer  += server_answer;
     server.offline += server_offline;
     server.BeginListener();
 }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        _server = new NetWorkServer(9999);

        gameObject.name = OBJ_NAME;
        DontDestroyOnLoad(gameObject);
        //gameObject.hideFlags = HideFlags.HideInHierarchy;
    }
示例#3
0
 public static void ServerRun(string ip, int port)
 {
     try
     {
         server          = new NetWorkServer(ip, port);
         server.answer  += server_answer;
         server.offline += server_offline;
         server.BeginListener();
     }
     catch (Exception e2)
     {
         MessageBox.Show("Server.ServerRun" + e2.Message);
     }
 }
示例#4
0
 static void Main(string[] args)
 {
     server         = new NetWorkServer("127.0.0.1", 10086); //监听9999端口
     server.answer += Answer;                                //如果收到信息,则执行Answer(托管)
     server.BeginListener();                                 //开始监听
     Console.WriteLine("Server Begin");
     while (true)
     {
         string command = Console.ReadLine();
         if (command == "exit")
         {
             return;
         }
     }
 }
示例#5
0
        void btn_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Friend f = null;

            foreach (var item in App.data.FriendList)
            {
                if (item.Value.isSelected)
                {
                    f              = (Friend)item.Value;
                    client         = new NetWorkClient(f.ip.ToString(), 6537);
                    client.answer += GetAnswers; //托管(回调)
                    client.Connect();            //开始连接
                    client.BeginListener();
                    break;
                }
            }
            if (f == null)
            {
                f              = API.Me;
                server         = new NetWorkServer(f.ip.ToString(), 6537);
                server.answer += Answer; //如果收到信息,则执行Answer(托管)
                server.BeginListener();  //开始监听
            }
            if (!f.Equals(API.Me))
            {
                client.Send("Info");
            }
            mainWindow = new MainWindow(f);
            mainWindow.Show();
            mainWindow.Focus();

            var func = runhandle;

            if (func != null)
            {
                func(this, new PluginRunEvent.PluginRunEventArgs(this));
            }
        }