private void MoverClientForm_Load(object sender, EventArgs e) { // 服务端通信 moverComm.StartClient(); // PLC通信 socketWrapper.Connect(); }
public bool connect(string ipaddr, int port, System.AsyncCallback callback) { // if (!Socket_.IsWorking_) Socket_.Init(ipaddr, port); Socket_Callback = callback; disconnect(); return(Socket_.Connect(ipaddr, port)); }
//------------------------------- lifetime -------------------------- public ClientController(string serverRemoteAddr, ushort serverPort, Int64 appId = 15) { socket = new SocketWrapper(serverRemoteAddr, 11000); applicationId = appId; socket.OnPacketsReceived += Sock_OnPacketsReceived; socket.OnConnect += Sock_OnConnect; socket.OnDisconnect += Sock_OnDisconnect; socket.Connect(); }
public TestClientToGatewayController(string gatewayRemoteAddr, ushort gatewayPort, Int64 appId = 15) { socket = new SocketWrapper("localhost", 11000); applicationId = appId; socket.OnPacketsReceived += Sock_OnPacketsReceived; socket.OnConnect += Sock_OnConnect; socket.OnDisconnect += Sock_OnDisconnect; socket.Connect(); }
public void OnStart() { socketWrapper = new SocketWrapper(); host = "ws://" + ServerAddressInputField.text + ":3001/socket.io/?EIO=4&transport=websocket"; Debug.Log(host); #if !UNITY_EDITOR socketWrapper.Connect(host); socketWrapper.OnReceiveMessenger += OnMessageArrived_Handler; socketWrapper.onDisconnect += OnDisconnect_Handler; #endif }
public TalkingToGatewayController(string gatewayRemoteAddr, ushort gatewayPort, MyPlayer player, Int64 appId) { Set(player); socket = new SocketWrapper(gatewayRemoteAddr, gatewayPort); applicationId = appId; socket.OnPacketsReceived += Sock_OnPacketsReceived; socket.OnConnect += Sock_OnConnect; socket.OnDisconnect += Sock_OnDisconnect; socket.Connect(); }
void ConnectToGateway() { if (gatewaySocket == null) { gatewaySocket = new SocketWrapper(gatewayServerSettings); gatewaySocket.OnPacketsReceived += Sock_OnPacketsReceived; gatewaySocket.OnConnect += Sock_OnConnect; gatewaySocket.OnDisconnect += Sock_OnDisconnect; gatewaySocket.Connect(); } }
private void Communication_Open() { var socket = new SocketWrapper(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)); try { socket.Connect(new IPEndPoint(IPAddress.Parse(Config.Current.IpAddress), Config.Current.ListenPort)); this.Communication_IdentifySelf(socket); this.Communication_Begin(socket); } catch (SocketException) // Server not running { this.IsConnectionInProgress = false; } }
//Connect socket to SERVER2. If status is disconnect private void OnDisconnection_handler(bool connect) { try { if (!connect) { //Edit ip socket socketWrapper.Connect("ws://172.16.6.10:3001/socket.io/?EIO=4&transport=websocket"); } else { Debug.WriteLine("Successfully Disconnect"); } } catch (System.Exception ex) { Debug.WriteLine(ex.Message); } }
//Disconnect Event Handler private void OnDisconnect_Handler(bool connect) { #if !UNITY_EDITOR try { if (!connect) { socketWrapper.Connect(host); } else { // text.text = "Successfully Disconnected"; } } catch (System.Exception ex) { Debug.Log(ex.Message); } #endif }
public void Connect() { socket?.Connect(); }
public MainPage() { this.InitializeComponent(); //Call the pointers of the screen. We use the pointers for draw and send position pointers = new Dictionary <uint, Windows.UI.Xaml.Input.Pointer>(); VideoBorder.PointerMoved += new PointerEventHandler(VideoBorder_PointerMoved); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; try { // connect to socket.io via other server when App start socketWrapper = new SocketWrapper(); socketWrapper.OnReceiveMessenger += OnReceivedMessage_handler; socketWrapper.onDisconnect += OnDisconnection_handler; socketWrapper.Connect("ws://172.16.6.10:3001/socket.io/?EIO=4&transport=websocket"); } catch (Exception ex) { Debug.WriteLine(ex.Message); } #if UNITY AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if UNITY_UWP if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); //splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } PeerVideo.Visibility = Visibility.Collapsed; SelfVideo.Visibility = Visibility.Collapsed; #else DXSwapChainPanel.Visibility = Visibility.Collapsed; #endif // UNITY }
private void Button_Click_2(object sender, RoutedEventArgs e) { if (clientsRunning != 0) { return; } Interlocked.Increment(ref clientsRunning); // Client start for (int c = 0; c < Clients; c++) { if (c != 0) { Interlocked.Increment(ref clientsRunning); } _clientTasks[c] = new Task(() => { while (true) { SocketWrapper[] clientSocketArr = new SocketWrapper[1]; SocketsWrapper.Socket(AddressFamily.QCC_AF_INET, SocketType.QCC_SOCK_STREAM, clientSocketArr); using (SocketWrapper clientSocket = clientSocketArr[0]) { uint q = clientSocket.Connect(Address, Port); byte[] tempBytes = new byte[PatternLength]; int[] receivedArr = new int[1]; int bytesLeft = tempBytes.Length; int byteCount = 0; bool success = true; do { q = clientSocket.Recv(tempBytes, tempBytes.Length, receivedArr); if (q != 0) { success = false; break; } for (int i = 0; i < receivedArr[0]; i++) { if (tempBytes[i] != ((i + byteCount) % 256)) { success = false; break; } } byteCount += receivedArr[0]; bytesLeft -= receivedArr[0]; }while (bytesLeft > 0); // Update the count Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (success) { successCount.Text = (++_successCount).ToString(); } else { failCount.Text = (++_failCount).ToString(); } }); } } Interlocked.Decrement(ref clientsRunning); }); _clientTasks[c].Start(); } }
public TestLoginController(string ipAddr, ushort port) { socket = new SocketWrapper(ipAddr, port); socket.OnPacketsReceived += ProcessReceiveBuffer; socket.Connect(); }