void IDriverPresenter.OnRegisterDriver() { try { DriverClient listener = new DriverClient(this); _scsClient = ScsServiceClientBuilder.CreateClient <IDriverServer>( new ScsTcpEndPoint(defaultIP, defaultPort), listener); _scsClient.Connect(); _server = _scsClient.ServiceProxy; _driverId = _view.GetDriverId(); if (_driverId != INVALID_DRIVER_ID) { _server.RegisterDriver(_driverId, 0); _view.OnConnected(); } else { _scsClient = null; _view.OnDisconnected(); } } catch (Exception) { _scsClient = null; _view.OnDisconnected(); } }
public void Connect() { _client = ScsServiceClientBuilder.CreateClient <INDistManagementService>(ScsEndPoint.CreateEndPoint(Address), _serverListener); _client.Connected += Client_Connected; _client.Disconnected += Client_Disconnected; _client.Connect(); }
private void Connect(object sender, RoutedEventArgs e) { if (ScsClient != null) { ScsClient.Disconnect(); } ScsClient = ScsServiceClientBuilder.CreateClient <IInformerService>( new ScsTcpEndPoint(ServerIp.Text, 23232), Client); ScsClient.Timeout = 1000; ScsClient.ConnectTimeout = 2000; ScsClient.Connected += OnScsConnnected; ScsClient.Disconnected += OnScsDisconnected; Log("Try connect..."); ThreadPool.QueueUserWorkItem( o => { try { ScsClient.Connect(); } catch { Log("Can't connect to server."); } }); }
void IDriverPresenter.RegisterDriver(int driverID) { try { _driverId = driverID; DriverClient listener = new DriverClient(this); _scsClient = ScsServiceClientBuilder.CreateClient <IDriverServer>( new ScsTcpEndPoint(defaultIP, defaultPort), listener); _scsClient.Connect(); _server = _scsClient.ServiceProxy; if (_driverId != INVALID_DRIVER_ID && _server.RegisterDriver(_driverId, 0) == 0) { NotifyConnected(); } else { _scsClient = null; NotifyDisconnected(); } } catch (Exception) { _scsClient = null; NotifyDisconnected(); } }
private void ConnectToLogin() { LoginBridge = ScsServiceClientBuilder.CreateClient <IGameServerContract>( new ScsTcpEndPoint(_loginIp, _loginPort)); LoginBridge.ConnectTimeout = 3000; //3 second for reconnection LoginBridge.Timeout = 1000; LoginBridge.Connected += (sender, args) => { try { LoginBridge.ServiceProxy.Auth(_authKey); LoginBridge.ServiceProxy.RegisterGs(_gsInfo); } catch (Exception) { Log.Error("Login server auth failed!"); _autoConnect = false; } }; LoginBridge.Disconnected += (sender, args) => { Log.Error("Login server disconnected"); TryToConnect(); }; TryToConnect(); }
public void HostNode() { using (var client = ScsServiceClientBuilder.CreateClient <IHostNodeRequestService>(new ScsTcpEndPoint(Ip, Port))) { client.Connect(); string nameLocation = "800 LANGDON ST, MADISON AU"; string posEntryMode = "021"; string posCondCode = "41"; // Cash Dispenser Machine (ATM) TranHostNodeRequestDto hostReq = new TranHostNodeRequestDto { P3ProcessingCode = "11", // from triton P4AmountTran = 12000, // from triton P7TransmitDt = DateTime.Now, //P11Stan = 1, P12TimeLocalTran = DateTime.Now, P13DateLocalTran = DateTime.Now, P15DateSettlement = DateTime.Now.AddDays(+1), P18MerchantType = "5811", P25PosConditionCode = posCondCode, P28AmtTranFee = 200, // from triton P35Track2 = "5188680100002932=15122015076719950000", // from triton v P41TerminalId = "S9218163", // from triton P43NameLocation = nameLocation, P52PinBlock = "A8FB4E47EACB0FA1", // from triton P57AmountCash = 0 // from triton }; TranHostNodeResponseDto hostRes = client.ServiceProxy.RequestTransaction(hostReq); // Send to HostNode } }
void IManagerPresenter.GetStatistics(DateTime?startDate, DateTime?endDate) { var scsClient = ScsServiceClientBuilder.CreateClient <IManagerServer>( new ScsTcpEndPoint(defaultIP, defaultPort), this); Statistics stat = scsClient.ServiceProxy. GetStatistics(startDate, endDate); _view.OnStatisticsUpdate(stat); }
/// <summary> /// /// </summary> /// <param name="host"></param> /// <returns></returns> private static IScsServiceClient <IMonetDbtcpService> GetFactory(string host) { var serviceClient = ScsServiceClientBuilder.CreateClient <IMonetDbtcpService>(new ScsTcpEndPoint(host, MonetSettings.Tcp.Port)); serviceClient.Timeout = MonetDbtcpSettings.Tcp.TimeOut; serviceClient.ConnectTimeout = MonetDbtcpSettings.Tcp.TimeOut; return(serviceClient); }
public void OnGetStatistics() { var scsClient = ScsServiceClientBuilder.CreateClient <IManagerServer>( new ScsTcpEndPoint(defaultIP, defaultPort), this); Statistics stat = scsClient.ServiceProxy. GetStatistics(_view.GetStartDate(), _view.GetEndDate()); _view.OnStatisticsUpdate(stat); }
void IManagerPresenter.OnGetRecommendations() { var scsClient = ScsServiceClientBuilder.CreateClient <IManagerServer>( new ScsTcpEndPoint(defaultIP, defaultPort), this); Recommendations recommend = scsClient.ServiceProxy. GetRecommendations(); System.Console.WriteLine(recommend.ToString()); _view.OnRecommendationsUpdate(recommend); }
public void Connect(string serverAddress, int serverPort) { try { HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this); HsClient.Connect(); HS = HsClient.ServiceProxy; var apiVersion = HS.APIVersion; // just to make sure our connection is valid hsTraceListener = new HSTraceListener(this as IDebugLogger); Debug.Listeners.Add(hsTraceListener); this.Log.HS = HS; } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting homeseer SCS client: {0}", ex.GetFullMessage()), ex ); } try { CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this); CallbackClient.Connect(); Callback = CallbackClient.ServiceProxy; var apiVersion = Callback.APIVersion; // just to make sure our connection is valid } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting callback SCS client: {0}", ex.GetFullMessage()), ex ); } // Establish the reverse connection from homeseer back to our plugin try { HS.Connect(Name, InstanceFriendlyName()); } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting homeseer to our plugin: {0}", ex.GetFullMessage()), ex ); } HsClient.Disconnected += HsClient_Disconnected; }
public bool Connect(string IP, int Port) { clientService = ScsServiceClientBuilder.CreateClient <ITaxiService>(new ScsTcpEndPoint(IP, Port)); try { clientService.Connect(); } catch { clientService.Dispose(); return(false); } return(true); }
static void Main() { Console.ReadLine(); //Create a client to connecto to phone book service on local server and 10048 TCP port. var client = ScsServiceClientBuilder.CreateClient <IPhoneBookService>(new ScsTcpEndPoint("127.0.0.1", 10048)); //Directly call a method (it automatically connects, calls and disconnects) client.ServiceProxy.AddPerson(new PhoneBookRecord { Name = "Halil ibrahim", Phone = "5881112233" }); Console.ReadLine(); }
public void Connect(string serverAddress, int serverPort) { // This method is called by our console wrapper at launch time // Create our main connection to the HomeSeer TCP communication framework // part 1 - hs object Proxy try { HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this); HsClient.Connect(); HS = HsClient.ServiceProxy; // ReSharper disable once UnusedVariable var apiVersion = HS.APIVersion; // just to make sure our connection is valid } catch (Exception ex) { throw new HspiConnectionException($"Error connecting HomeSeer SCS client: {ex.Message}", ex); } // part 2 - callback object Proxy try { CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>( new ScsTcpEndPoint(serverAddress, serverPort), this); CallbackClient.Connect(); Callback = CallbackClient.ServiceProxy; // ReSharper disable once UnusedVariable var apiVersion = Callback.APIVersion; // just to make sure our connection is valid } catch (Exception ex) { throw new HspiConnectionException($"Error connecting callback SCS client: {ex.Message}", ex); } // Establish the reverse connection from HomeSeer back to our plugin try { HS.Connect(Name, InstanceFriendlyName()); } catch (Exception ex) { throw new HspiConnectionException($"Error connecting HomeSeer to our plugin: {ex.Message}", ex); } }
public void GetExamCopy() { // try { HighSecurity = highSecChkBox.Checked; //Create a client to connecto to phone book service on local server and //10048 TCP port. client = ScsServiceClientBuilder.CreateClient <INetworkExamService>( new ScsTcpEndPoint(ipTxtBox.Text, int.Parse(portTxtBox.Text))); // client.Timeout = 3; aLogger.LogMessage($"Trying to connect to the server (timeout {client.Timeout} Seconds)", LogMsgType.Verbose); //Connect to the server client.Connect(); aLogger.LogMessage("Connected to server", LogMsgType.Verbose); RequiredDetails requiredDetails = new RequiredDetails(studentNameTxtBox.Text, studentIDTxtBox.Text, examKeyTxtBox.Text, (HighSecurity? sharedKeyISTxtBox.Text:"Low Security Settings Selected")); //Add some persons var copy = client.ServiceProxy.GetExamCopyEncryptedZipped(requiredDetails); requiredDetails.DecryptDetails(examKeyTxtBox.Text); if (!ExamHelper.ValidateExamCopy(copy, examKeyTxtBox.Text, aLogger, sharedKeyISTxtBox.Text, (highSecChkBox.Checked ? Security.FilterationSecurityLevel.High : Security.FilterationSecurityLevel.Moderate), requiredDetails.SequenceNumber)) { return; } aLogger.LogMessage("Received Exam Copy", LogMsgType.Verbose); aLogger.LogMessage("Checking Exam Copy...", LogMsgType.Verbose); var exam = Quizez.ExamHelper.GetExamFromByteArray(copy, examKeyTxtBox.Text, sharedKeyISTxtBox.Text, (highSecChkBox.Checked?Security.FilterationSecurityLevel.High:Security.FilterationSecurityLevel.Moderate)); aLogger.LogMessage("Exam Checked Correcly ...", LogMsgType.Verbose); //Disconnect from server // client.Disconnect(); // aLogger.LogMessage("Disconnected from server", LogMsgType.Verbose); anExam = exam; } // catch (Exception ex) { // aLogger.LogMessage(ex.Message, LogMsgType.Error); } }
public void Connect(string serverAddress, int serverPort) { Trace.WriteLine(Invariant($"Connecting to {serverAddress}")); try { HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this); HsClient.Connect(); HS = HsClient.ServiceProxy; #pragma warning disable S1481 // Unused local variables should be removed var apiVersion = HS.APIVersion; // just to make sure our connection is valid #pragma warning restore S1481 // Unused local variables should be removed hsTraceListener = new HSTraceListener(this as ILogger); Debug.Listeners.Add(hsTraceListener); } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting homeseer SCS client: {ex.GetFullMessage()}"), ex); } try { CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this); CallbackClient.Connect(); Callback = CallbackClient.ServiceProxy; #pragma warning disable S1481 // Unused local variables should be removed var apiVersion = Callback.APIVersion; // just to make sure our connection is valid #pragma warning restore S1481 // Unused local variables should be removed } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting callback SCS client: {ex.GetFullMessage()}"), ex); } // Establish the reverse connection from homeseer back to our plugin try { HS.Connect(Name, InstanceFriendlyName()); } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting homeseer to our plugin: {ex.GetFullMessage()}"), ex); } HsClient.Disconnected += HsClient_Disconnected; Trace.WriteLine(Invariant($"Connected to {serverAddress}")); }
static void Main(string[] args) { using (var client = ScsServiceClientBuilder.CreateClient <ISay>(new ScsTcpEndPoint("127.0.0.1", 10088))) { //Connect to the server client.Connect(); //Call a remote method of server var message = client.ServiceProxy.Say(); //Write the result to the screen Console.WriteLine("Result: " + message); } Console.WriteLine("Press enter to stop client application"); Console.ReadLine(); }
private void loginButton_Click(object sender, EventArgs e) { client = ScsServiceClientBuilder.CreateClient <IBugTrackerService>(new ScsTcpEndPoint("127.0.0.1", 10048)); client.Connect(); userInfo = new UserInfo(); userInfo.Username = usernameField.Text; userInfo.Password = passwordField.Text; if (client.ServiceProxy.Login(userInfo)) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Wrong username or password"); } }
static void Main() { ServerOpt so = new ServerOpt(); Client = new InformerClient(); Client.OnMessage += Console.WriteLine; Client.OnAuthed += () => { Console.WriteLine("Authed..."); new Thread(SendOnlineUpdates).Start(); }; ScsClient = ScsServiceClientBuilder.CreateClient <IInformerService> (new ScsTcpEndPoint(so.serverip, so.informerPort), Client); ScsClient.Timeout = ScsClient.ConnectTimeout = 2500; ScsClient.Connected += (sender, args) => { Console.WriteLine("Connected..."); ScsClient.ServiceProxy.Auth(so.sercurityKey); }; while (true) { try { if (ScsClient.CommunicationState == CommunicationStates.Disconnected) { ScsClient.Connect(); } while (ScsClient.CommunicationState == CommunicationStates.Connected) { Thread.Sleep(1000); } } catch { } SendUpdate(); //Offline } }
public void Connect(string username, string password) { try { _client = ScsServiceClientBuilder.CreateClient <ISpeechAPI>(new ScsTcpEndPoint(IpAddress, 10401), this); _client.Disconnected += OnClientDisconnect; _client.Connected += OnClientConnect; } catch (Exception exception) { Console.WriteLine($"Error occured while initializing the speaker client : {exception.Message}"); return; } Console.WriteLine($"Connecting speaker client {ClientName} to HomeSeer IP {IpAddress}"); _username = username; _password = password; Connect(1); }
public ReversalCoreNodeResponseDto RequestReversal(ReversalTritonNodeRequestDto req) { using (var client = ScsServiceClientBuilder.CreateClient <IHostNodeRequestService>(new ScsTcpEndPoint(Config.HostIpAddress, Config.HostPort))) { client.Connect(); ReversalCoreNodeResponseDto autResponseDto; IReversalService svr = new ReversalService(); var reversalReq = svr.ReversalRequest(req); if (reversalReq != null) { _log.Debug("Sending Core Request Object"); ReversalHostNodeResponseDto res = client.ServiceProxy.RequestReversal(reversalReq); // Send to HostNode _log.Debug("Getting Host Response Object"); autResponseDto = new ReversalCoreNodeResponseDto { Stan = res.Stan, ResponseCode = res.ResponseCode, ResponseDescription = res.ResponseDescription, ResponseAction = res.ResponseAction, AmountTran = res.AmountTran, AmtTranFee = res.AmtTranFee, AmountCash = res.AmountCash, TranSeqNo = res.TranSeqNo }; } else { _log.Debug("Pin Translation failed, sending response."); //send response back to terminal for decline autResponseDto = new ReversalCoreNodeResponseDto { ResponseCode = "99", ResponseDescription = "Pin Translation Error", ResponseAction = "Decline transaction", TranSeqNo = req.TranSeqNo, AmountTran = req.Amount1, AmtTranFee = req.Amount2 }; } return(autResponseDto); } }
/// <summary> /// Connects to the server. /// It automatically Logins to server if connection success. /// </summary> public void Connect() { //Disconnect if currently connected Disconnect(); //Create a ChatClient to handle remote method invocations by server _chatClient = new ChatClient(ChatRoom); //Create a SCS client to connect to SCS server _scsClient = ScsServiceClientBuilder.CreateClient <IChatService>(new ScsTcpEndPoint(LoginForm.ServerIpAddress, LoginForm.ServerTcpPort), _chatClient); //Register events of SCS client _scsClient.Connected += ScsClient_Connected; _scsClient.Disconnected += ScsClient_Disconnected; //Connect to the server _scsClient.Connect(); }
/// <summary> /// Connects to the server. /// It automatically Logins to server if connection success. /// </summary> public void Connect() { //Disconnect if currently connected Disconnect(); //Create a ChatClient to handle remote method invocations by server _bugTrackerClient = new BugTrackerClient(BugProcess); //Create a SCS client to connect to SCS server _scsClient = ScsServiceClientBuilder.CreateClient <IBugTrackerService>(new ScsTcpEndPoint("localhost", 10048), _bugTrackerClient); //Register events of SCS client _scsClient.Connected += ScsClient_Connected; _scsClient.Disconnected += ScsClient_Disconnected; //Connect to the server _scsClient.Connect(); }
static void Main() { Console.WriteLine("Press enter to connect to server and call methods..."); Console.ReadLine(); //Create a client that can call methods of Calculator Service that is running on local computer and 10083 TCP port //Since IScsServiceClient is IDisposible, it closes connection at the end of the using block using (var client = ScsServiceClientBuilder.CreateClient <ICalculatorService>(new ScsTcpEndPoint("127.0.0.1", 10083))) { //Connect to the server client.Connect(); //Call a remote method of server double resultado = 0; //resultado = client.ServiceProxy.Divide(42, 3); //Write the result to the screen // Console.WriteLine("Result division: " + resultado); double resultado2 = 0; string mensaje = ""; string[] otrosValores = new string[2] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; int k = 100; string[] otrosValores2 = null; // double multiplicar(double a, double b, ref double resultado, out string mensaje, string[] otrosValores, ref int k, bool haceAlgo, out string[] otrosValores2); resultado = client.ServiceProxy.multiplicar(42, 3, ref resultado2, out mensaje, otrosValores, ref k, true, out otrosValores2); //Write the result to the screen Console.WriteLine("Result multiplicar: " + resultado + " resultado2: " + resultado2 + " mensaje:" + mensaje + " k: " + k); if (otrosValores2 != null) { foreach (string c in otrosValores2) { Console.WriteLine("Otros valores2 " + c); } } } Console.WriteLine("Press enter to stop client application"); Console.ReadLine(); }
/// <summary> /// Konfiguracja sieci i połączenie /// </summary> /// public static void NetworkConfiguration() { Data = new UserSession(); Data.Client = ScsServiceClientBuilder.CreateClient <IPokerService>(new ScsTcpEndPoint("127.0.0.1", 10048), PokerClient.Instance); _reconnector = new ClientReConnecter(Data.Client) { ReConnectCheckPeriod = 1000 }; try { Data.Client.ConnectTimeout = 3000; Data.Client.Connect(); } catch (Exception ex) { Console.WriteLine("Błąd podczas łączenia z siecią"); } }
/// <summary> /// Connects to the server. /// It automatically Logins to server if connection success. /// </summary> public void Connect() { //Disconnect if currently connected Disconnect(); //Create a ChatClient to handle remote method invocations by server _chatClient = new ChatClient(FormView); //Create a SCS client to connect to SCS server _scsClient = ScsServiceClientBuilder.CreateClient <IMsgService>(new ScsTcpEndPoint("127.0.0.1", 9000), _chatClient); //Register events of SCS client _scsClient.Connected += ScsClient_Connected; _scsClient.Disconnected += ScsClient_Disconnected; //Connect to the server _scsClient.Connect(); }
static void Main() { //Create a client to connecto to phone book service on local server and 10048 TCP port. var client = ScsServiceClientBuilder.CreateClient <IPhoneBookService>( new ScsTcpEndPoint("127.0.0.1", 10048)); Console.WriteLine("Press enter to connect to phone book service..."); Console.ReadLine(); //Connect to the server client.Connect(); var person1 = new PhoneBookRecord { Name = "Halil ibrahim", Phone = "5881112233" }; var person2 = new PhoneBookRecord { Name = "John Nash", Phone = "58833322211" }; //Add some persons client.ServiceProxy.AddPerson(person1); client.ServiceProxy.AddPerson(person2); //Search for a person var person = client.ServiceProxy.FindPerson("Halil"); if (person != null) { Console.WriteLine("Person is found:"); Console.WriteLine(person); } else { Console.WriteLine("Can not find person!"); } Console.WriteLine(); Console.WriteLine("Press enter to disconnect from phone book service..."); Console.ReadLine(); //Disconnect from server client.Disconnect(); }
public CommunicationServiceClient() { string ip = ConfigurationManager.AppSettings["MasterIP"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); _commClient = new CommunicationClient(); _client = ScsServiceClientBuilder.CreateClient <ICommunicationService>(new ScsTcpEndPoint(ip, port), _commClient); while (_client.CommunicationState != CommunicationStates.Connected) { try { _client.Connect(); } catch { Logger.Log.Error(Language.Instance.GetMessageFromKey("RETRY_CONNECTION")); Thread.Sleep(2000); } } }
public void Connect(string serverAddress, int serverPort) { hsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>( new ScsTcpEndPoint(serverAddress, serverPort), this); hsClient.Connect(); hs = hsClient.ServiceProxy; Program.HsClient = hs; // make sure we're connected successfully double apiVersion = hs.APIVersion; callbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this); callbackClient.Connect(); callbacks = callbackClient.ServiceProxy; apiVersion = callbacks.APIVersion; hs.Connect(this.Name, this.InstanceFriendlyName()); }
public AuthentificationServiceClient() { string ip = ConfigurationManager.AppSettings["MasterIP"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); _client = ScsServiceClientBuilder.CreateClient <IAuthentificationService>(new ScsTcpEndPoint(ip, port)); System.Threading.Thread.Sleep(1000); while (_client.CommunicationState != CommunicationStates.Connected) { try { _client.Connect(); } catch (Exception) { Logger.Error(Language.Instance.GetMessageFromKey("RETRY_CONNECTION"), memberName: nameof(AuthentificationServiceClient)); System.Threading.Thread.Sleep(1000); } } }