//单例模式"懒汉式" public static CSCore GetInstance() { if (instance == null) { instance = new CSCore(); } return(instance); }
public ChatWindow() { InitializeComponent(); CSCore_instance = CSCore.GetInstance(); P2PCore_instance = P2PCore.GetInstance(); //P2PCore_instance.BeginListen(); FileBuffer = new byte[FileMaxSize]; inter = InterThreads.GetInstance(); ChattingMessageList = new ObservableCollection <ChattingMessage>(); }
private P2PCore() { receiveBuffer = new byte[bufferSize]; //内部通信线程 inter = InterThreads.GetInstance(); //本机IP IP = GetMyIPv4(); endpoint = new IPEndPoint(IP, Port); //tcp和udp监听线程 tcplistener = new TcpListener(IP, Port); Udplistener = new UdpClient(endpoint); //初始化已发送的Udp的消息的List UdpMessageList = new List <UdpData>(); //用于发送Udp ack信号的CSCore CSCore_instance = CSCore.GetInstance(); }
//private List<string> ChattingGroupList public MainWindow() { InitializeComponent(); //LoginProcess(); CSCore_instance = CSCore.GetInstance(); P2PCore_instance = P2PCore.GetInstance(); P2PCore_instance.BeginListen(); inter = InterThreads.GetInstance(); //MessageBox.Show("Listen Start!"); lock (inter) inter.processing = true; MsgPump = new Thread(ReceiveListener) { Name = "MessagePump" }; }
private void Login_Loaded(object sender, RoutedEventArgs e) { CSCore_instance = CSCore.GetInstance(); }
public AddFriend() { InitializeComponent(); CSCore_instance = CSCore.GetInstance(); }