public static void ServerRun(string ip, int port) { server = new NetWorkServer(ip, port); server.answer += server_answer; server.offline += server_offline; server.BeginListener(); }
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); } }
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; } } }
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)); } }