public static void Answer(object sender, AnswerEventArgs args) { if (args.data.ToString().Equals("Info")) { if (di != null) { server.ServerSendAll(di); } } else if (args.data.ToString().Equals("Data")) { Queue <DirectoryInfo> qd = new Queue <DirectoryInfo>(); if (di != null) { DirectoryInfo tmp = di; qd.Enqueue(tmp); while (qd.Count > 0) { server.ServerSendAll(qd.Peek()); foreach (FileInfo fi in qd.Peek().GetFiles()) { FileStream fs = new FileStream(fi.FullName, FileMode.Open); server.ServerSendAll(fs); } foreach (DirectoryInfo d in qd.Peek().GetDirectories()) { qd.Enqueue(d); } qd.Dequeue(); } server.ServerSendAll("Done"); } } }
static void server_offline(object sender, ServerAcceptEventArgs args) { Debug.WriteLine("OffLine!"); var str = tcpmap[sender as TcpClient]; server.ServerSendAll(new UserMessage(8, str, 0)); }
static void server_offline(object sender, ServerAcceptEventArgs args) { try{ Debug.WriteLine("OffLine!"); var str = tcpmap[sender as TcpClient]; server.ServerSendAll(new UserMessage(8, str, 0)); } catch (Exception e2) { MessageBox.Show("Server.server_offline" + e2.Message); } }