示例#1
0
        /// <summary>
        /// 初始化所有对象,并初始化类
        /// </summary>
        public void Init()
        {
            Client       = new UDPThread(_client);                                //文本网络对象
            LivedHost    = new OnlineHost(this.Config);                           //主机列表
            MessageProxy = new MessageTranslator(Client, this.Config, LivedHost); //文本信息翻译层对象

            //自动查询主机客户端版本
            LivedHost.HostOnline += (s, e) =>
            {
                if (Config.AutoDetectVersion)
                {
                    this.GetVersion(e.Host);
                }
            };

            //文件传输
            FileTaskManager = new FileTaskManager(this.Config);
            FileTaskManager.FileReceiveTaskDiscarded += (s, e) => this.SendReleaseFilesSignal(e.TaskInfo.RemoteHost, e.TaskInfo.PackageID);
            FileTaskModule = new FSLib.IPMessager.Network.TCPThread(_client)
            {
                TaskManager = FileTaskManager
            };


            //与接收消息进行挂钩
            MessageProxy.MessageReceived += MessageProxy_MessageReceived;
        }
示例#2
0
        static void Main(string[] args)
        {
            UDPThread     udp  = new UDPThread(7777);
            MsgTranslator tran = new MsgTranslator(udp);

            tran.MessageReceived += tran_MessageReceived;
        }
示例#3
0
文件: Form1.cs 项目: zyok/ZZNetFrame
        public Form1()
        {
            InitializeComponent();
            UDPThread client = new UDPThread(textBox1.Text, 6666);

            tan = new MsgTranslator(client);
            tan.MessageReceived += MessageReceived;
            tan.DebugEvent      += Debug;
        }
示例#4
0
文件: Form1.cs 项目: zyok/ZZNetFrame
        public Form1()
        {
            log = new LogInfo("log.txt");
            InitializeComponent();
            UDPThread client = new UDPThread(6666);

            tan = new MsgTranslator(client);
            tan.MessageReceived += MessageReceived;
            tan.DebugEvent      += Debug;
        }
示例#5
0
        public Form1()
        {
            InitializeComponent();
            Config cfg = SeiClient.GetDefaultConfig();

            cfg.Port = 7777;
            UDPThread udp = new UDPThread(cfg);

            tran = new MsgTranslator(udp, cfg);
            tran.MessageReceived += tran_MessageReceived;
        }
示例#6
0
        static void Main(string[] args)
        {
            UDPThread     udp  = new UDPThread("58.198.176.217", 7777);
            MsgTranslator tran = new MsgTranslator(udp);

            tran.MessageReceived += tran_MessageReceived;
            IPEndPoint remote = new IPEndPoint(IPAddress.Any, 7777);
            Msg        m      = new Msg(remote, "zz", "zhujun", Commands.Join, "test1", "test2");

            m.PackageNo = 12345678;
            tran.Send(m);
        }
示例#7
0
 void Update() {
     if (callback == null)
         return;
     if (thread != null && !thread.IsDone) {
         thread.Update();
     }
     if (thread.IsDone) {
         thread.OnFinished();
         Debug.Log("UDP-Update: Thread is done. Starting another");
         thread = new UDPThread(callback);
         thread.Start();
     }
 }
示例#8
0
    public IPEndPoint OpenClient(IPEndPoint local_udp_endpoint)
    {
        if (udpThreadState != null)
        {
            StopClient();
            udpThreadState = null;
        }
        udpThreadState = new UDPThread();
        IPEndPoint localEndPoint = udpThreadState.Open(local_udp_endpoint);

        runningThread = new Thread(new ThreadStart(udpThreadState.mythread));
        runningThread.Start();
        return(localEndPoint);
    }
示例#9
0
 void Update()
 {
     if (callback == null)
     {
         return;
     }
     if (thread != null && !thread.IsDone)
     {
         thread.Update();
     }
     if (thread.IsDone)
     {
         thread.OnFinished();
         Debug.Log("UDP-Update: Thread is done. Starting another");
         thread = new UDPThread(callback);
         thread.Start();
     }
 }
示例#10
0
 void Start() {
     thread = new UDPThread(callback);
     thread.Start();
     Debug.Log("UDP-Start: Created thread");
 }
示例#11
0
 public IPEndPoint OpenSendOnlyClient(IPEndPoint local_udp_endpoint)
 {
     runningThread  = null;
     udpThreadState = new UDPThread();
     return(udpThreadState.Open(local_udp_endpoint));
 }
示例#12
0
 // -------------------------------------------------------------------------
 void Start()
 {
     _udpThread = GetComponentInChildren<UDPThread>();
     _udpThread.eventDataReceived += new Action<object, byte[]>(OnDataReceived);
 }
示例#13
0
 void Start()
 {
     thread = new UDPThread(callback);
     thread.Start();
     Debug.Log("UDP-Start: Created thread");
 }