コード例 #1
0
		public void LoadSettings(RelayNodeDefinition node, RelayNodeGroupDefinition group)
		{
			MySpace.SocketTransport.SocketSettings newSettings = BuildSettings(group.SocketSettings);
			if (newSettings.SameAs(settings)) return;
			IDisposable disposableObject = null;
			try
			{
				settings = newSettings;
				socketClient = new SocketClient(node.IPEndPoint, settings);
				disposableObject = asyncSocketClient;
				asyncSocketClient = new AsyncSocketClient(node.IPEndPoint, new SocketPoolConfig
				{
					ReceiveTimeout = settings.ReceiveTimeout,
					NetworkOrdered = settings.UseNetworkOrder,
					ConnectTimeout = settings.ConnectTimeout,
					LoanCapacity = settings.PoolSize
				});
			}
			finally
			{
				if (disposableObject != null)
				{
					try
					{
						asyncSocketClient.Dispose();
					}
					catch (Exception ex)
					{
						log.Error("Failed to dispose AsyncSocketClient", ex);
					}
				}
			}
		}
コード例 #2
0
        // Start is called before the first frame update
        public void InitiateConnection(string consUsed, int score, int amountWordsFound, bool accepted, string usedWords)
        {
            Debug.Log("Initiated connection from Client");
            Thread t_PerthOut = new Thread(() => AsyncSocketClient.StartClient(consUsed, score, amountWordsFound, accepted, usedWords));

            t_PerthOut.Start();
        }
コード例 #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Client started!");
     Console.WriteLine("Press any key to start......");
     Console.ReadLine();
     AsyncSocketClient.StartClient();
     Console.ReadLine();
 }
コード例 #4
0
        //连接自定义的socket服务器
        public void StartConnectSocketServer()
        {
            // Establish the remote endpoint for the socket.
//            IPHostEntry ipHostInfo = Dns.GetHostEntry("localHost");
//            IPAddress ipAddress = ipHostInfo.AddressList[0];
//            IPEndPoint remoteEP = new IPEndPoint(ipAddress, ipPort);
            IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("127.0.0.1"), ipPort);

            asyncSocketClient = new AsyncSocketClient();
            asyncSocketClient.Start(remoteEP);
        }
コード例 #5
0
        private void ManagerConnect()
        {
            manager_socket_ = new AsyncSocketClient(0);

            // 이벤트 핸들러 재정의
            manager_socket_.OnConnet  += new AsyncSocketConnectEventHandler(OnConnet);
            manager_socket_.OnClose   += new AsyncSocketCloseEventHandler(OnClose);
            manager_socket_.OnSend    += new AsyncSocketSendEventHandler(OnSend);
            manager_socket_.OnReceive += new AsyncSocketReceiveEventHandler(OnReceive);
            manager_socket_.OnError   += new AsyncSocketErrorEventHandler(OnError);
            manager_socket_.Connect(CrawlerInfoManager.Instance.managerip_, CrawlerInfoManager.Instance.managerport_);
        }
コード例 #6
0
ファイル: CrawlerVer2.cs プロジェクト: Youkyungjin/Crawler
        // 체커 연결
        private void CheckerConnect()
        {
            //NewLogManager2.Instance.Log("private void CheckerConnect()");
            Checker_Socket_ = new AsyncSocketClient(1);

            Checker_Socket_.OnConnet  += new AsyncSocketConnectEventHandler(OnConnet);
            Checker_Socket_.OnClose   += new AsyncSocketCloseEventHandler(OnClose);
            Checker_Socket_.OnSend    += new AsyncSocketSendEventHandler(OnSend);
            Checker_Socket_.OnReceive += new AsyncSocketReceiveEventHandler(OnReceive);
            Checker_Socket_.OnError   += new AsyncSocketErrorEventHandler(OnError);
            Checker_Socket_.Connect("127.0.0.1", CINIManager.Instance.checkerport_);
        }
コード例 #7
0
        private void CheckerConnect()
        {
            LogManager.Instance.Log("private void CheckerConnect()");
            checker_socket_ = new AsyncSocketClient(1);

            // 이벤트 핸들러 재정의
            checker_socket_.OnConnet  += new AsyncSocketConnectEventHandler(OnConnet);
            checker_socket_.OnClose   += new AsyncSocketCloseEventHandler(OnClose);
            checker_socket_.OnSend    += new AsyncSocketSendEventHandler(OnSend);
            checker_socket_.OnReceive += new AsyncSocketReceiveEventHandler(OnReceive);
            checker_socket_.OnError   += new AsyncSocketErrorEventHandler(OnError);
            checker_socket_.Connect("127.0.0.1", CrawlerInfoManager.Instance.checkerport_);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: zhilangtaosha/elearning
        public static void Main(string[] args)
        {
            AsyncSocketClientReceive.LittleEndian   = true;
            AsyncSocketClientReceive.MaxPackageSize = 1024 * 1024;
            AsyncSocketClientReceive.ErrorMsg       = ClientMsg;
            AsyncSocketClientReceive.RegisterEvent <LoginEvent>(Command.Login);
            AsyncSocketClientReceive.RegisterEvent <FriendsEvent>(Command.Friends);
            AsyncSocketClientReceive.RegisterEvent <LabaEvent>(Command.Laba);
            AsyncSocketClientReceive.RegisterEvent <LabaEvent>(Command.BigData);

            client               = new AsyncSocketClient(4096);
            client.Connected    += new EventHandler <AsyncSocketTokenEventArgs>(client_Connected);    //连接成功
            client.Disconnected += new EventHandler <AsyncSocketTokenEventArgs>(client_Disconnected); //断开连接
            client.DataReceived += new EventHandler <AsyncSocketTokenEventArgs>(client_DataReceived); //接收到数据
            client.Error        += new EventHandler <AsyncSocketErrorEventArgs>(client_Error);        //出错
            client.Connect("tcp://127.0.0.1:3000");                                                   //连接服务器

            Thread.Sleep(10000000);
        }
コード例 #9
0
 public ServerProcessor(AsyncSocketClient client, ISMSStorageProvider storagerProvider, IBillingProvider provider)
 {
     communicator                  = new SMPPCommunicator();
     storage                       = storagerProvider;
     communicator.Disposed        += new EventHandler(communicator_Disposed);
     communicator.OnAlert         += new SMPPCommunicator.AlertEventHandler(communicator_OnAlert);
     communicator.OnBind          += new SMPPCommunicator.BindEventHandler(communicator_OnBind);
     communicator.OnCancelSm      += new SMPPCommunicator.CancelSmEventHandler(communicator_OnCancelSm);
     communicator.OnClose         += new SMPPCommunicator.ClosingEventHandler(communicator_OnClose);
     communicator.OnDataSm        += new SMPPCommunicator.DataSmEventHandler(communicator_OnDataSm);
     communicator.OnDeliverSm     += new SMPPCommunicator.DeliverSmEventHandler(communicator_OnDeliverSm);
     communicator.OnDeliverSmResp += new SMPPCommunicator.DeliverSmRespEventHandler(communicator_OnDeliverSmResp);
     communicator.OnEnquireLink   += new SMPPCommunicator.EnquireLinkEventHandler(communicator_OnEnquireLink);
     communicator.OnError         += new SMPPCommunicator.ErrorEventHandler(communicator_OnError);
     communicator.OnQuerySm       += new SMPPCommunicator.QuerySmEventHandler(communicator_OnQuerySm);
     communicator.OnReplaceSm     += new SMPPCommunicator.ReplaceSmEventHandler(communicator_OnReplaceSm);
     communicator.OnSubmitMulti   += new SMPPCommunicator.SubmitMultiEventHandler(communicator_OnSubmitMulti);
     communicator.OnSubmitSm      += new SMPPCommunicator.SubmitSmEventHandler(communicator_OnSubmitSm);
     communicator.OnUnbind        += new SMPPCommunicator.UnbindEventHandler(communicator_OnUnbind);
     communicator.ProcessServerClient(client);
 }
コード例 #10
0
        // Button Connetti
        private void Btn_Connetti_Click(object sender, RoutedEventArgs e)
        {
            // Controlli generali
            if (Txt_Username.Text == "Nome utente")
            {
                MessageBox.Show("Attenzione, devi inserire un nome utente", "Attenzione", MessageBoxButton.OK, MessageBoxImage.Warning);
                Txt_Username.Focus();
                return;
            }

            if (Txt_IpAddress.Text == "Indirizzo IP")
            {
                MessageBox.Show("Attenzione, devi inserire un indirizzo IP", "Attenzione", MessageBoxButton.OK, MessageBoxImage.Warning);
                Txt_IpAddress.Focus();
                return;
            }

            if (Txt_porta.Text == "Numero porta")
            {
                MessageBox.Show("Attenzione, devi inserire un numero di porta", "Attenzione", MessageBoxButton.OK, MessageBoxImage.Warning);
                Txt_porta.Focus();
                return;
            }

            // Creazione istanza
            client = new AsyncSocketClient();

            // Passaggio dei parametri ai metodi
            client.SetServerIPAddress(Txt_IpAddress.Text);
            client.SetServerPort(Txt_porta.Text);

            // Connessione al server
            client.ConnettiAlServer();
            client.Invia(Txt_Username.Text);

            Chat chat = new Chat();

            chat.Show();
            this.Hide();
        }