Beispiel #1
0
 public DataClientClass(string username, IScsServiceClient client, IDataAdminService clientProxy)
 {
     _username = username;
         Client = client;
         ClientProxy = clientProxy;
         AllowedSymbolGroups = new List<int>();
 }
Beispiel #2
0
 public CollectorClient(string username, int idDB,IScsServiceClient tclient, IDataNormalizatorService ticknetproxy)
 {
     _username = username;
        _idDatabase = idDB;
     TickNetProxy = ticknetproxy;
     TickNetClient = tclient;
 }
        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.");
                        }
                    });
        }
Beispiel #4
0
 public void Connect()
 {
     _client = ScsServiceClientBuilder.CreateClient<INDistManagementService>(ScsEndPoint.CreateEndPoint(Address), _serverListener);
     _client.Connected += Client_Connected;
     _client.Disconnected += Client_Disconnected;
     _client.Connect();
 }
Beispiel #5
0
        public void ConnectionTest()
        {
            //Disconnect if currently connected

            //Create a ChatClient to handle remote method invocations by server
            //_chatClient = this;

            //Create a SCS client to connect to SCS server
            //The 2nd parameter is EXTREMELY important to note and must be non-null if you want to have Server -> Client callbacks.
            _scsClient = ScsServiceClientBuilder.CreateClient<IChatService>(
                new ScsTcpEndPoint("127.0.0.1", 10048), this );

            //Register events of SCS client
            _scsClient.Connected += ScsClient_Connected;
            _scsClient.Disconnected += ScsClient_Disconnected;

            //Connect to the server
            _scsClient.Connect();

            Thread.Sleep(5000);

            _scsClient.ServiceProxy.SendMessageToRoom(new ChatMessage("Hi Everyone"));

            Console.ReadKey();
        }
Beispiel #6
0
 public NDistServiceNode(IScsServiceClient<INDistManagementService> client, NDistServerListener serverListener, ServiceInfo service)
 {
     Service = service;
     _client = client;
     _serverListener = serverListener;
     _serverListener.ServiceRunningStatusChanged += ServerListener_ServiceRunningStatusChanged;
 }
Beispiel #7
0
 public DataClient(string username, int idDB, IScsServiceClient dclient, IScsServiceClient tclient, IDataAdminService dclientProxy,IDataAdminService tclientProxy, bool datanet, bool ticknet)
 {
     _username = username;
     DnetClient = dclient;
     TnetClient = tclient;
     DClientProxy = dclientProxy;
     TClientProxy = tclientProxy;
     _idDatabase = idDB;
     IsDatanetConnected = datanet;
     IsTickNetConnected = ticknet;
 }
Beispiel #8
0
        /// <summary>
        /// Disconnects from server if it is connected.
        /// </summary>
        public void Disconnect()
        {
            if (_scsClient != null && _scsClient.CommunicationState == CommunicationStates.Connected)
            {
                try
                {
                    _scsClient.Disconnect();
                }
                catch
                {

                }

                _scsClient = null;
            }
        }
Beispiel #9
0
        /// <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();
        }
Beispiel #10
0
        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 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)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[Info] Connection will be established");
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
Beispiel #12
0
        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);
            System.Threading.Thread.Sleep(1000);
            while (_client.CommunicationState != CommunicationStates.Connected)
            {
                try
                {
                    _client.Connect();
                }
                catch (Exception)
                {
                    Logger.Error(Language.Instance.GetMessageFromKey("RETRY_CONNECTION"), memberName: nameof(CommunicationServiceClient));
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
Beispiel #13
0
        private void OnMainFormClosing(Object sender
                                       , FormClosingEventArgs e)
        {
            Timer.Stop();

            if (m_ChangeNotificationObject != null)
            {
                TransactionObject transactionObject = m_RemoteAccessClient.ServiceProxy.BeginTransaction();

                m_RemoteAccessClient.ServiceProxy.UnregisterForProfileChanges(transactionObject, m_ChangeNotificationObject, true);

                m_ChangeNotificationObject = null;
            }

            if (m_RemoteAccessClient != null)
            {
                m_RemoteAccessClient.Disconnect();
                m_RemoteAccessClient.Dispose();
                m_RemoteAccessClient = null;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Connects to Homeseer at the specified server address and port.
        /// This is called by the console wrapper.
        /// </summary>
        /// <param name="serverAddress">The server address.</param>
        /// <param name="serverPort">The server port.</param>
        /// <exception cref="Exception"> Error connecting homeseer SCS client </exception>
        /// <exception cref="Exception"> Error connecting callback SCS client </exception>
        /// <exception cref="Exception"> Error connecting homeseer to our plugin </exception>
        public virtual void Connect(string serverAddress, int serverPort)
        {
            // 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;
                double APIVersion = hs.APIVersion;          // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new Exception("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;
                double APIVersion = callback.APIVersion;    // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting callback SCS client: " + ex.Message, ex);
            }

            // Establish the reverse connection from homeseer back to our plugin
            try
            {
                hs.Connect(IFACE_NAME, INSTANCE_NAME);
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting homeseer to our plugin: " + ex.Message, ex);
            }
        }
Beispiel #15
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (LoginBox.Text == "" || PasswordBox.Password == "")
            {
                MessageBox.Show("Incorrect login or password");
                return;
            }
            try
            {
                LauncherService =
                    ScsServiceClientBuilder.CreateClient <ILauncherContract>(
                        new ScsTcpEndPoint("127.0.0.1", 6667));

                LauncherService.ConnectTimeout = 3000;
                LauncherService.Timeout        = 1000;

                LauncherService.Connect();

                StartingSequence(LauncherService.ServiceProxy.RegisterClientToken(LoginBox.Text, PasswordBox.Password));


                if (RememberBox.IsChecked != null && RememberBox.IsChecked.Value)
                {
                    using (StreamWriter sw = new StreamWriter(".\\cfg.ini"))
                    {
                        sw.WriteLine("{0}@{1}", LoginBox.Text, PasswordBox.Password);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Close();
            }
        }
Beispiel #16
0
 /// <summary>
 /// Creates a new ServiceClientEventArgs object.
 /// </summary>
 /// <param name="client">Client that is associated with this event</param>
 public ServiceClientEventArgs(IScsServiceClient client)
 {
     Client = client;
 }
Beispiel #17
0
 public InformerClient(IScsServiceClient client, IInformerClient proxy)
 {
     Client = client;
     Proxy  = proxy;
 }
Beispiel #18
0
 private void GsserviceOnClientConnected(object sender, ServiceClientEventArgs serviceClientEventArgs)
 {
     _authedClient = serviceClientEventArgs.Client;
 }
        /// <summary>
        /// Raises ClientDisconnected event.
        /// </summary>
        /// <param name="client"></param>
        private void OnClientDisconnected(IScsServiceClient client)
        {
            EventHandler <ServiceClientEventArgs> handler = ClientDisconnected;

            handler?.Invoke(this, new ServiceClientEventArgs(client));
        }
Beispiel #20
0
 public void RegisterGs(GsInfo gsInfo)
 {
     ConnectedServers.Add(_authedClient, gsInfo);
     Log.Info("Server [{0}] has been available", gsInfo.ServerName);
     _authedClient = null;
 }
        public static void Main(string[] args)
        {
            string serverIp = "127.0.0.1";

            string serverCmd = null;

            foreach (string serverCmd_loopVariable in args)
            {
                serverCmd = serverCmd_loopVariable;
                string[] ch = new string[1];
                ch[0] = "=";
                string[] parts = serverCmd.Split(ch, StringSplitOptions.None);
                switch (parts[0].ToLower())
                {
                case "server":
                    serverIp = parts[1];
                    break;

                case "instance":
                    try
                    {
                        Util.Instance = parts[1];
                    }
                    catch (Exception)
                    {
                        Util.Instance = "";
                    }
                    break;
                }
            }
Reconnect:
            Console.WriteLine("Plugin: " + Util.IFACE_NAME + " Instance: " + Util.Instance + " starting...");
            Console.WriteLine("Connecting to server at " + serverIp + "...");
            client         = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverIp, 10400), plugin);
            clientCallback = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverIp, 10400), plugin);
            int Attempts = 1;

TryAgain:

            try
            {
                client.Connect();
                clientCallback.Connect();

                double APIVersion = 0;

                try
                {
                    host       = client.ServiceProxy;
                    APIVersion = host.APIVersion;
                    // will cause an error if not really connected
                    Console.WriteLine("Host API Version: " + APIVersion.ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error getting API version from host object: " + ex.Message + "->" + ex.StackTrace);
                    //Return
                }

                try
                {
                    callback   = clientCallback.ServiceProxy;
                    APIVersion = callback.APIVersion;
                    // will cause an error if not really connected
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error getting API version from callback object: " + ex.Message + "->" + ex.StackTrace);
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot connect attempt " + Attempts.ToString() + ": " + ex.Message);
                if (ex.Message.ToLower().Contains("timeout occurred."))
                {
                    Attempts += 1;
                    if (Attempts < 6)
                    {
                        goto TryAgain;
                    }
                }

                if (client != null)
                {
                    client.Dispose();
                    client = null;
                }
                if (clientCallback != null)
                {
                    clientCallback.Dispose();
                    clientCallback = null;
                }
                wait(4);
                return;
            }

            try
            {
                connectionJunction();
                if (reset)
                {
                    HSPI.armReset();
                    goto Reconnect;
                }
                else
                {
                    System.Environment.Exit(0);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot connect(2): " + ex.Message);
                wait(2);
                System.Environment.Exit(0);
                return;
            }
        }
Beispiel #22
0
 public static ClientModel GetUser(IScsServiceClient Client)
 {
     return(PokerService.Instance.Clients.FirstOrDefault(c => c.Client.ClientId == Client.ClientId));
 }
Beispiel #23
0
 /// <summary>
 /// Creates a new ChatClient object.
 /// </summary>
 /// <param name="client">Scs client reference</param>
 /// <param name="clientProxy">Proxy object to call remote methods of chat client</param>
 /// <param name="userInfo">User informations of client</param>
 public PokerClient(IScsServiceClient client, IPokerClient clientProxy, UserModel userInfo)
 {
     Client      = client;
     ClientProxy = clientProxy;
     User        = userInfo;
 }
Beispiel #24
0
        public void AddClient(IScsServiceClient newClient, char listflag, UserModel usrModel)
        {
            var client = CurrentClient;

            //Get a proxy object to call methods of client when needed
            var clientProxy = CurrentClient.GetClientProxy<IDataAdminService>();
            //Create a DataClient and store it in a collection
            bool dnet = listflag == 'd';
            bool tnet = listflag == 't';
            bool dexp = listflag == 'e';
            var dataClient = new DataClient(usrModel.Name, usrModel.Id, dnet, tnet) {IsDexportConnected = dexp};

            if (dnet)
            {
                dataClient.DClientProxy = clientProxy;
                dataClient.DnetClient = CurrentClient;
                CurrentLoginTypeDnet = true;
                CurrentLoginTypeTnet = false;
                CurrentLoginTypeDexp = false;
                dataClient.DexportProxy = null;
                dataClient.TnetClient = null;

            }
            if (tnet)
            {
                dataClient.TClientProxy = clientProxy;
                dataClient.TnetClient = CurrentClient;
                CurrentLoginTypeTnet = true;
                CurrentLoginTypeDnet = false;
                CurrentLoginTypeDexp = false;
                dataClient.DnetClient = null;
                dataClient.DexportProxy = null;

            }
            if (dexp)
            {
                dataClient.DexportProxy = clientProxy;
                dataClient.DexportClient = CurrentClient;
                CurrentLoginTypeDexp = true;
                CurrentLoginTypeTnet = false;
                CurrentLoginTypeDnet = false;
                dataClient.DnetClient = null;
                dataClient.TnetClient = null;

            }

            dataClient.IndexInAdminList = (int) client.ClientId;
            Clients[client.ClientId] = dataClient;

            //Register to Disconnected event to know when user connection is closed
            client.Disconnected += Client_Disconnected;
            //Start a new task to send user list to mainform

            if (OnloggedInLog != null)
            {
                var msg = new DataAdminMessageFactory.LogMessage
                              {
                                  OperationStatus = DataAdminMessageFactory.LogMessage.Status.Finished,
                                  LogType = DataAdminMessageFactory.LogMessage.Log.Login,
                                  Time = DateTime.Now,
                                  UserID = usrModel.Id,
                                  IsDataNetClient = CurrentLoginTypeDnet,
                                  IsTickNetClient = CurrentLoginTypeTnet,
                              };
                var msgMain = "Client " + usrModel.Name + " connected from " + CurrentClient.RemoteEndPoint;
                OnloggedInLog(msg, msgMain);
            }
            OnClientLogon(usrModel);
            Task.Factory.StartNew(OnUserListChanged);
        }
Beispiel #25
0
 public NDistServicesNode(IScsServiceClient <INDistManagementService> client, NDistServerListener serverListener)
 {
     _client         = client;
     _serverListener = serverListener;
 }
Beispiel #26
0
 public Speler(int id, string name, IScsServiceClient client)
 {
     this.ID = id;
     this.Name = name;
     this.Client = client;
 }
        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();
        }
Beispiel #28
0
        /// <summary>
        /// Raises ClientConnected event.
        /// </summary>
        /// <param name="client"></param>
        private void OnClientConnected(IScsServiceClient client)
        {
            var handler = ClientConnected;

            handler?.Invoke(this, new ServiceClientEventArgs(client));
        }
 public InformerClient(IScsServiceClient client, IInformerClient proxy)
 {
     Client = client;
     Proxy = proxy;
 }
Beispiel #30
0
 public LogClient(IScsServiceClient client)
 {
     Client = client;
     ClientProxy = client.GetClientProxy<IDataNetLogService>();
 }
 public MainWindow(IScsServiceClient <VoldeMoveis_CommonLib.IVoldeMoveisService> client, User user)
 {
     this._user  = user;
     this.client = client;
     InitializeComponent();
 }
Beispiel #32
0
 public CoreCommunicationService(IScsServiceClient <ICoreNodeRequestService> proxyClient)
 {
     _proxyClient = proxyClient;
 }
 public ConnectedClient(IScsServiceClient client)
 {
     Client = client;
     Proxy = client.GetClientProxy<INDistManagementServiceClient>();
 }
        //----------------------------------------------------------------------
        // Initialize
        //----------------------------------------------------------------------
        public ClientMain(string[] args)
        {
            //開啟之後特殊模式判別,雙擊開啟不會有任何特殊模式
            string strMode = "";
            int iMode = 0;
            try
            {
                strMode = args[0];
                iMode = int.Parse(strMode);
            }
            catch { }
            switch (iMode)
            {
                case 0: quoteProgramMode = QuoteProgramModeOS.QPM_Neutural;
                    Console.WriteLine("當前模式為 Client 一般雙擊開啟");
                    break;
                case 1: quoteProgramMode = QuoteProgramModeOS.QPM_AllProduct;
                    Console.WriteLine("當前模式為  Server 取得當前商品列表");
                    break;
                case 3: quoteProgramMode = QuoteProgramModeOS.QPM_MarketAM;
                    Console.WriteLine("當前模式為  Client  小日經上午盤中作單模式");
                    break;
                case 4: quoteProgramMode = QuoteProgramModeOS.QPM_AMMarketTickGet;
                    Console.WriteLine("當前模式為  Client  小日經上午盤後Tick資訊擷取,上午倉位紀錄");
                    break;
                case 5: quoteProgramMode = QuoteProgramModeOS.QPM_MarketPM;
                    Console.WriteLine("當前模式為  Client  小日經下午盤作單模式");
                    break;
                case 6: quoteProgramMode = QuoteProgramModeOS.QPM_AfterMarket;
                    Console.WriteLine("當前模式為  Client  小日經下午盤後Tick資訊擷取,寫入每日歷史紀錄");
                    break;
            }

            InitializeComponent();

            fConnect = new FOnConnect(OnConnect);
            GC.KeepAlive(fConnect);

            fQuoteUpdate = new FOnGetStockIdx(OnQuoteUpdate);
            GC.KeepAlive(fQuoteUpdate);

            fNotifyTicks = new FOnNotifyTicks(OnNotifyTicks);
            GC.KeepAlive(fNotifyTicks);

            fOnNotifyBest5 = new FOnGetStockIdx(OnNotifyBest5);
            GC.KeepAlive(fOnNotifyBest5);

            fOverseaProducts = new FOnOverseaProducts(OnOverseaProducts);
            GC.KeepAlive(fOverseaProducts);

            fNotifyServerTime = new FOnNotifyServerTime(OnNotifyServerTime);
            GC.KeepAlive(fNotifyServerTime);

            fNotifyKLineData = new FOnNotifyKLineData(OnNotifyKLineData);
            GC.KeepAlive(fNotifyKLineData);

            fOnNotifyTicksGet = new FOnNotifyTicksGet(OnNotifyTicksGet);
            GC.KeepAlive(fOnNotifyTicksGet);

            m_Logger = new Logger();

            client = ScsServiceClientBuilder.CreateClient<IOSQuoteService>(new ScsTcpEndPoint("127.0.0.1", 10083));

            g_marketStartTime_AM = new DateTime(todate.Year, todate.Month, todate.Day, 9, 0, 0);

            g_marketEndTime_AM = new DateTime(todate.Year, todate.Month, todate.Day, 15, 15, 59);

            g_marketStartTime_PM = new DateTime(todate.Year, todate.Month, todate.Day, 16, 29, 59);

            DateTime nxDate = todate.AddDays(1);
            g_marketEndTime_PM = new DateTime(nxDate.Year, nxDate.Month, nxDate.Day, 3, 0, 0);

            //上午收盤前10分,啟動timer時間
            g_marketNearEndTime_AM = g_marketEndTime_AM.AddMinutes(-10);

            //上午收盤前10分,啟動timer時間
            g_marketNearEndTime_PM = g_marketEndTime_PM.AddMinutes(-10);

            this.tabControl1.SelectTab(1);
        }
        public void run()
        {
            string[] cmdArgs = Environment.GetCommandLineArgs();
            Console.WriteLine("Manager::run() - arguments are {0}", Environment.CommandLine);
            String paramServer = "127.0.0.1";
            String paramInstance = "";
            foreach (string arg in cmdArgs)
            {
                Console.WriteLine(" - arg: {0}", arg);
                if (arg.Contains("="))
                {
                    String[] ArgS = arg.Split('=');
                    Console.WriteLine(" -- {0}=>{1}", ArgS[0], ArgS[1]);
                    switch (ArgS[0])
                    {
                        case "server":
                            paramServer = ArgS[1];
                            break;
                        case "instance":
                            paramInstance = ArgS[1];
                            break;
                        default:
                            Console.WriteLine("Unhandled param: {0}", ArgS[0]);
                            break;

                    }
                }
            }
            pluginInst = new HSPI(paramInstance);

            //Environment.CommandLine.
            client = ScsServiceClientBuilder.CreateClient<IHSApplication>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);
            clientCB = ScsServiceClientBuilder.CreateClient<IAppCallbackAPI>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);

            try
            {
                client.Connect();
                clientCB.Connect();
                hsHost = client.ServiceProxy;
                double ApiVer = hsHost.APIVersion;
                Console.WriteLine("Host ApiVersion : {0}", ApiVer);
                hsHostCB = clientCB.ServiceProxy;
                ApiVer = hsHostCB.APIVersion;
                Console.WriteLine("Host CB ApiVersion : {0}", ApiVer);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot start instance because of : {0}", e.Message);
                return;
            }
            Console.WriteLine("Connection to HS succeeded!");
            try
            {
                pluginInst.hsHost = hsHost;
                pluginInst.hsHostCB = hsHostCB;
                hsHost.Connect(pluginInst.Name, "");
                Console.WriteLine("Connected, waiting to be initialized...");
                do
                {
                    Thread.Sleep(500);
                } while (client.CommunicationState == CommunicationStates.Connected && pluginInst.Running);

                Console.WriteLine("Connection lost, exiting");
                pluginInst.Running = false;

                client.Disconnect();
                clientCB.Disconnect();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to host connect: {0}", e.Message);
                return;
            }

            Console.WriteLine("Exiting!!!");
        }
Beispiel #36
0
 /// <summary>
 /// Creates a new ServiceClientEventArgs object.
 ///
 /// </summary>
 /// <param name="client">Client that is associated with this event</param>
 public ServiceClientEventArgs(IScsServiceClient client)
 {
     this.Client = client;
 }
        /// <summary>
        /// Handles MessageReceived events of all clients, evaluates each message, finds appropriate
        /// service object and invokes appropriate method.
        /// </summary>
        /// <param name="sender">Source of event</param>
        /// <param name="e">Event arguments</param>
        private void Client_MessageReceived(object sender, MessageEventArgs e)
        {
            // Get RequestReplyMessenger object (sender of event) to get client
            RequestReplyMessenger <IScsServerClient> requestReplyMessenger = (RequestReplyMessenger <IScsServerClient>)sender;

            // Cast message to ScsRemoteInvokeMessage and check it
            if (!(e.Message is ScsRemoteInvokeMessage invokeMessage))
            {
                return;
            }

            try
            {
                // Get client object
                IScsServiceClient client = _serviceClients[requestReplyMessenger.Messenger.ClientId];
                if (client == null)
                {
                    requestReplyMessenger.Messenger.Disconnect();
                    return;
                }

                // Get service object
                ServiceObject serviceObject = _serviceObjects[invokeMessage.ServiceClassName];
                if (serviceObject == null)
                {
                    SendInvokeResponse(requestReplyMessenger, invokeMessage, null, new ScsRemoteException("There is no service with name '" + invokeMessage.ServiceClassName + "'"));
                    return;
                }

                // Invoke method
                try
                {
                    // Set client to service, so user service can get client in service method using
                    // CurrentClient property.
                    object returnValue;
                    serviceObject.Service.CurrentClient = client;
                    try
                    {
                        returnValue = serviceObject.InvokeMethod(invokeMessage.MethodName, invokeMessage.Parameters);
                    }
                    finally
                    {
                        // Set CurrentClient as null since method call completed
                        serviceObject.Service.CurrentClient = null;
                    }

                    // Send method invocation return value to the client
                    SendInvokeResponse(requestReplyMessenger, invokeMessage, returnValue, null, invokeMessage.Parameters);
                }
                catch (TargetInvocationException ex)
                {
                    Exception innerEx = ex.InnerException;
                    if (innerEx != null)
                    {
                        SendInvokeResponse(requestReplyMessenger, invokeMessage, null, new ScsRemoteInvocationException(invokeMessage.ServiceClassName, serviceObject.ServiceAttribute?.Version ?? "", invokeMessage.MethodName, innerEx.Message, innerEx));
                    }
                }
                catch (Exception ex)
                {
                    SendInvokeResponse(requestReplyMessenger, invokeMessage, null, new ScsRemoteInvocationException(invokeMessage.ServiceClassName, serviceObject.ServiceAttribute?.Version ?? "", invokeMessage.MethodName, ex.Message, ex));
                }
            }
            catch (Exception ex)
            {
                SendInvokeResponse(requestReplyMessenger, invokeMessage, null, new ScsRemoteException("An error occured during remote service method call.", ex));
            }
        }
 public CommunicationClient(IScsServiceClient client, ICommunicationClient clientProxy, ModuleInfo userInfo)
 {
     Client      = client;
     ClientProxy = clientProxy;
     User        = userInfo;
 }
Beispiel #39
0
 public LogClient(IScsServiceClient client)
 {
     Client      = client;
     ClientProxy = client.GetClientProxy <IDataNetLogService>();
 }
        public static void Main(string[] args)
        {
            string serverIp = "127.0.0.1";

            string serverCmd = null;

            foreach (string serverCmd_loopVariable in args)
            {
                serverCmd = serverCmd_loopVariable;
                string[] ch = new string[1];
                ch[0] = "=";
                string[] parts = serverCmd.Split(ch, StringSplitOptions.None);
                switch (parts[0].ToLower())
                {
                case "server":
                    serverIp = parts[1];
                    break;

                case "instance":
                    try
                    {
                        Util.Instance = parts[1];
                    }
                    catch (Exception)
                    {
                        Util.Instance = "";
                    }
                    break;
                }
            }

            Console.WriteLine("Plugin: " + Util.IFACE_NAME + " Instance: " + Util.Instance + " starting...");
            Console.WriteLine("Connecting to server at " + serverIp + "...");
            client         = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverIp, 10400), plugin);
            clientCallback = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverIp, 10400), plugin);
            int Attempts = 1;

TryAgain:

            try
            {
                client.Connect();
                clientCallback.Connect();

                double APIVersion = 0;

                try
                {
                    host       = client.ServiceProxy;
                    APIVersion = host.APIVersion;
                    // will cause an error if not really connected
                    Console.WriteLine("Host API Version: " + APIVersion.ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error getting API version from host object: " + ex.Message + "->" + ex.StackTrace);
                    //Return
                }

                try
                {
                    callback   = clientCallback.ServiceProxy;
                    APIVersion = callback.APIVersion;
                    // will cause an error if not really connected
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error getting API version from callback object: " + ex.Message + "->" + ex.StackTrace);
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot connect attempt " + Attempts.ToString() + ": " + ex.Message);
                if (ex.Message.ToLower().Contains("timeout occurred."))
                {
                    Attempts += 1;
                    if (Attempts < 6)
                    {
                        goto TryAgain;
                    }
                }

                if (client != null)
                {
                    client.Dispose();
                    client = null;
                }
                if (clientCallback != null)
                {
                    clientCallback.Dispose();
                    clientCallback = null;
                }
                wait(4);
                return;
            }

            try
            {
                // create the user object that is the real plugin, accessed from the pluginAPI wrapper
                Util.callback = callback;
                Util.hs       = host;
                plugin.OurInstanceFriendlyName = Util.Instance;
                // connect to HS so it can register a callback to us
                host.Connect(Util.IFACE_NAME, Util.Instance);
                Console.WriteLine("Connected, waiting to be initialized...");
                do
                {
                    System.Threading.Thread.Sleep(10);
                } while (client.CommunicationState == HSCF.Communication.Scs.Communication.CommunicationStates.Connected & !HSPI.bShutDown);
                Console.WriteLine("Connection lost, exiting");
                // disconnect from server for good here
                client.Disconnect();
                clientCallback.Disconnect();
                wait(2);
                System.Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot connect(2): " + ex.Message);
                wait(2);
                System.Environment.Exit(0);
                return;
            }
        }
 private void OnScsDisconnected(object sender, EventArgs e)
 {
     Log("Disconnected.");
     ScsClient = null;
 }
Beispiel #42
0
        private bool LoginToNormalizer(string host)
        {
            var serverStatus = true;
            var succesLogin = true;

            var tcpClient = new TcpClient();
            try
            {
                tcpClient.Connect(host, 442);
            }
            catch (Exception ex)
            {
                ToastNotification.Show(this, "The DataNormalizer is not available.");
                Console.Write(ex.Message);
                serverStatus = false;

            }
            if (serverStatus)
            {

                _dataNormalizatorClient = new DataNormalizatorClient();
                _dnormClientService =
                   ScsServiceClientBuilder.CreateClient<IDataNormalizatorService>(new ScsTcpEndPoint(host, 442),
                                                                                  _dataNormalizatorClient);

                try
                {
                    _dnormClientService.Connect();
                    _dnormClientService.ServiceProxy.Login(new DataNormalizatorMessageFactory.LoginMessage()
                                                            {
                                                                Username = _client.UserName,
                                                                IsLoginedToDa = true,
                                                                ServerMessage = ""
                                                            });
                    _normalizerStatus = true;
                }
                catch (Exception)
                {
                    succesLogin = false;
                    _normalizerStatus = false;
                }

                if (succesLogin)
                {
                    _dnormClientService.Disconnected += OnDNormCrashed;
                    _dataNormalizatorClient.OnActivation += CollectActivated;
                    _dataNormalizatorClient.OnDeactivation += CollectDeactivated;
                }
            }
            else succesLogin = false;

            return succesLogin;
        }
 /// <summary>
 /// Creates a new ServiceClientEventArgs object.
 /// </summary>
 /// <param name="client">Client that is associated with this event</param>
 public ServiceClientEventArgs(IScsServiceClient client) => Client = client;
 private void OnScsDisconnected(object sender, EventArgs e)
 {
     Log("Disconnected.");
     ScsClient = null;
 }
Beispiel #45
0
 public ConnectedClient(IScsServiceClient client)
 {
     Client = client;
     Proxy  = client.GetClientProxy <INDistManagementServiceClient>();
 }
Beispiel #46
0
        public void AddClient(IScsServiceClient newClient, char listflag, UserModel usrModel)
        {
            var client = CurrentClient;

            //Get a proxy object to call methods of client when needed
            var clientProxy = CurrentClient.GetClientProxy <IDataAdminService>();
            //Create a DataClient and store it in a collection
            bool dnet       = listflag == 'd';
            bool tnet       = listflag == 't';
            bool dexp       = listflag == 'e';
            var  dataClient = new DataClient(usrModel.Name, usrModel.Id, dnet, tnet)
            {
                IsDexportConnected = dexp
            };

            if (dnet)
            {
                dataClient.DClientProxy = clientProxy;
                dataClient.DnetClient   = CurrentClient;
                CurrentLoginTypeDnet    = true;
                CurrentLoginTypeTnet    = false;
                CurrentLoginTypeDexp    = false;
                dataClient.DexportProxy = null;
                dataClient.TnetClient   = null;
            }
            if (tnet)
            {
                dataClient.TClientProxy = clientProxy;
                dataClient.TnetClient   = CurrentClient;
                CurrentLoginTypeTnet    = true;
                CurrentLoginTypeDnet    = false;
                CurrentLoginTypeDexp    = false;
                dataClient.DnetClient   = null;
                dataClient.DexportProxy = null;
            }
            if (dexp)
            {
                dataClient.DexportProxy  = clientProxy;
                dataClient.DexportClient = CurrentClient;
                CurrentLoginTypeDexp     = true;
                CurrentLoginTypeTnet     = false;
                CurrentLoginTypeDnet     = false;
                dataClient.DnetClient    = null;
                dataClient.TnetClient    = null;
            }

            dataClient.IndexInAdminList = (int)client.ClientId;
            Clients[client.ClientId]    = dataClient;

            //Register to Disconnected event to know when user connection is closed
            client.Disconnected += Client_Disconnected;
            //Start a new task to send user list to mainform

            if (OnloggedInLog != null)
            {
                var msg = new DataAdminMessageFactory.LogMessage
                {
                    OperationStatus = DataAdminMessageFactory.LogMessage.Status.Finished,
                    LogType         = DataAdminMessageFactory.LogMessage.Log.Login,
                    Time            = DateTime.Now,
                    UserID          = usrModel.Id,
                    IsDataNetClient = CurrentLoginTypeDnet,
                    IsTickNetClient = CurrentLoginTypeTnet,
                };
                var msgMain = "Client " + usrModel.Name + " connected from " + CurrentClient.RemoteEndPoint;
                OnloggedInLog(msg, msgMain);
            }
            OnClientLogon(usrModel);
            Task.Factory.StartNew(OnUserListChanged);
        }
Beispiel #47
0
        private void OnGetAllIdsButtonClick(Object sender
                                            , EventArgs e)
        {
            if (m_RemoteAccessClient == null)
            {
                m_RemoteAccessClient = ScsServiceClientBuilder.CreateClient <IDVDProfilerRemoteAccess>(new ScsTcpEndPoint(IPAddressTextBox.Text, 10083));

                m_RemoteAccessClient.Connect();
            }

            ProfileIdListView.Items.Clear();

            TransactionObject transactionObject = m_RemoteAccessClient.ServiceProxy.BeginTransaction();

            if (m_ChangeNotificationObject == null)
            {
                AccessResult <ChangeNotificationObject> result = m_RemoteAccessClient.ServiceProxy.RegisterForProfileChanges(transactionObject, false);

                m_ChangeNotificationObject = result.Result;

                Timer.Interval = 5000;
                Timer.Tick    += new EventHandler(OnTimer1Tick);
            }

            Timer.Stop();

            try
            {
                AccessResult <List <String> > result = m_RemoteAccessClient.ServiceProxy.GetAllProfileIds(transactionObject, false);

                if (result.Success)
                {
                    if (result.Result != null)
                    {
                        foreach (String profileId in result.Result)
                        {
                            ListViewItem item = new ListViewItem();

                            GetTitle(transactionObject, profileId, item);

                            ProfileIdListView.Items.Add(item);
                        }
                    }

                    m_RemoteAccessClient.ServiceProxy.CommitTransaction(transactionObject);
                }
                else
                {
                    m_RemoteAccessClient.ServiceProxy.AbortTransaction(transactionObject);

                    MessageBox.Show("An error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Timer.Start();
            }
            catch (Exception ex)
            {
                try
                {
                    m_RemoteAccessClient.ServiceProxy.AbortTransaction(transactionObject);
                }
                catch { }

                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (LoginBox.Text == "" || PasswordBox.Password == "")
            {
                MessageBox.Show("Incorrect login or password");
                return;
            }
            try
            {

                LauncherService =
                    ScsServiceClientBuilder.CreateClient<ILauncherContract>(
                        new ScsTcpEndPoint("127.0.0.1", 6667));

                LauncherService.ConnectTimeout = 3000;
                LauncherService.Timeout = 1000;

                LauncherService.Connect();

                StartingSequence(LauncherService.ServiceProxy.RegisterClientToken(LoginBox.Text, PasswordBox.Password));

                if (RememberBox.IsChecked != null && RememberBox.IsChecked.Value)
                {
                    using (StreamWriter sw = new StreamWriter(".\\cfg.ini"))
                    {
                        sw.WriteLine("{0}@{1}", LoginBox.Text, PasswordBox.Password);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Close();
            }
        }
Beispiel #49
0
        private void LoginToServer(string username, string password, string host)
        {
            _pingTimer.Enabled = false;
            _client = new DataClientClass(username);
            _logClient = new DataNetLogService();

            _serverHost = host;
            _logClientService = ScsServiceClientBuilder.CreateClient<IDataNetLogService>(new ScsTcpEndPoint(host, 443), _logClient);
            _clientService = ScsServiceClientBuilder.CreateClient<IDataAdminService>(new ScsTcpEndPoint(host, 443), _client);

            _clientService.Connected += ScsClient_Connected;

            try
            {
                _clientService.Connect();
                _logClientService.Connect();
                _client.login += LoggedIn;
                _client.block += BlockedByAdmin;
                _client.loginFailed += LoginFailed;
                _client.changePrivilages += ChangedPrivileges;
                _client.logout += DeletedClient;
                _client.symblolListRecieved += GroupSymbolChange;
                _client.symbolListChanged += RefreshSymbols;
                _client.groupChanged += RefreshGroups;
                _client.logoutServer += ServerStatusChanged;
                _client.busySymbolListReceived += BusySymbolChanged;
                _client.symbolPermissionChanged += RefreshSymbols;
                _clientService.Disconnected += OnServerCrashed;

                var logmsg = new DataAdminMessageFactory.LogMessage { Symbol = username, LogType = DataAdminMessageFactory.LogMessage.Log.Login, Group = "" };

                _logClientService.ServiceProxy.SendSimpleLog(logmsg);
                Settings.Default.connectionHost = _startControl.ui_textBox_ip.Text;

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (_startControl != null)
                    _startControl.Invoke((Action)(() =>
                    {
                        ToastNotification.Show(_startControl, "Can't connect. IP is incorrect");
                        _startControl.ui_buttonX_logon.Enabled = true;
                    }
                        ));

                return;
            }
            var loginMsg = new DataAdminMessageFactory.LoginMessage(username, password, 't');
            try
            {
                _clientService.ServiceProxy.Login(loginMsg);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #50
0
 public void RegisterGs(GsInfo gsInfo)
 {
     ConnectedServers.Add(_authedClient, gsInfo);
     Log.Info("Server [{0}] has been available", gsInfo.ServerName);
     _authedClient = null;
 }
Beispiel #51
0
 public NDistServicesNode(IScsServiceClient<INDistManagementService> client, NDistServerListener serverListener)
 {
     _client = client;
     _serverListener = serverListener;
 }
 /// <summary>
 /// Creates a new BugTrackerClient object.
 /// </summary>
 /// <param name="client">Scs client reference</param>
 /// <param name="clientProxy">Proxy object to call remote methods of BugTracker client</param>
 /// <param name="userInfo">User informations of client</param>
 public BugTrackerClient(IScsServiceClient client, IBugTrackerClient clientProxy, UserInfo userInfo)
 {
     Client      = client;
     ClientProxy = clientProxy;
     User        = userInfo;
 }
Beispiel #53
0
 /// <summary>
 /// Creates a new ChatClient object.
 /// </summary>
 /// <param name="client">Scs client reference</param>
 /// <param name="clientProxy">Proxy object to call remote methods of chat client</param>
 /// <param name="userInfo">User informations of client</param>
 public ChatClient(IScsServiceClient client, IChatClient clientProxy, UserInfo userInfo)
 {
     Client      = client;
     ClientProxy = clientProxy;
     User        = userInfo;
 }
        public bool Connect(string username, string password)
        {
            lock (objlock)
            {
                string ipAddress = "127.0.0.1";

                Logger.LogInfo("Connecting speaker client {0} to HomeSeer IP {1}", _clientName, ipAddress);

                try
                {
                    _client = ScsServiceClientBuilder.CreateClient <ISpeechAPI>(new ScsTcpEndPoint(ipAddress, 10401), this);
                    _client.Disconnected += new EventHandler(ClientDisconnected);
                    _client.Connected    += new EventHandler(ClientConnected);
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                    return(false);
                }

                try
                {
                    _client.Connect();
                    _speakHost = _client.ServiceProxy;
                    //make sure the interface is supported
                    int v;
                    try
                    {
                        v = _speakHost.version();
                    }
                    catch (Exception e)
                    {
                        Logger.LogError("Error attempting to connect to server, please check your connection options: {0}", e.Message);
                        return(false);
                    }

                    if (v != SPEAKER_INTERFACE_VERSION)
                    {
                        Logger.LogError("Speaker API version mismatch");
                        return(false);
                    }

                    //string localIp = Util.GetLocalIp();
                    string rval = _speakHost.Connect("Sample Plugin", _clientName, "127.0.0.1", username, password);

                    if (!string.IsNullOrEmpty(rval))
                    {
                        Logger.LogError("Error, Unable to connect speaker client interface: {0}", rval);
                        DisconnectNow();
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError("Error while connecting speaker client: {0}", e.ToString());
                    return(false);
                }
            }

            return(true);
        }
Beispiel #55
0
        private void LoginToServer(string username, string password, string host, bool isMaster)
        {
            _logonThread = new Thread(
                () =>
                {
                    _pingTimer.Enabled = false;
                    _client = new DataClientClass(username);
                    _logClient = new DataNetLogService();
                    _logClientService =
                        ScsServiceClientBuilder.CreateClient<IDataNetLogService>(new ScsTcpEndPoint(host, 443),
                            _logClient);
                    _clientService =
                        ScsServiceClientBuilder.CreateClient<IDataAdminService>(new ScsTcpEndPoint(host, 443), _client);
                    _clientService.Connected += ScsClient_Connected;

                    try
                    {
                        _clientService.Connect();
                        _logClientService.Connect();

                        _client.login += LoggedIn;
                        _client.block += BlockedByAdmin;
                        _client.loginFailed += LoginFailed;
                        _client.changePrivilages += ChangedPrivileges;
                        _client.logout += DeletedClient;
                        _client.symblolListRecieved += GroupSymbolChange;
                        _client.symbolListChanged += RefreshSymbols;
                        _client.groupChanged += RefreshGroups;
                        //_client.logoutServer += ServerStatusChanged;
                        _client.busySymbolListReceived += BusySymbolChanged;
                        _client.symbolPermissionChanged += RefreshSymbols;
                        _clientService.Disconnected += OnServerCrashed;

                        var logmsg = new DataAdminMessageFactory.LogMessage
                        {
                            Symbol = username,
                            LogType = DataAdminMessageFactory.LogMessage.Log.Login,
                            Group = ""
                        };

                        _logClientService.ServiceProxy.SendSimpleLog(logmsg);
                        Settings.Default.scHost = _startControl.ui_textBox_ip.Text;
                        Settings.Default.scHostSlave = _startControl.ui_textBox_ip_slave.Text;
                        Invoke((Action) (() =>
                        {
                            labelItem_server.Text = isMaster ? "Master" : "Slave";
                            styleManager1.MetroColorParameters = new MetroColorGeneratorParameters(Color.White,
                                isMaster ? Color.Green : Color.YellowGreen);

                            metroStatusBar1.Refresh();
                        }));

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        if (_startControl != null)
                            _startControl.Invoke((Action) (() =>
                            {
                                if (isMaster)
                                {
                                    ToastNotification.Show(_startControl, "Can't connect. IP is incorrect");
                                    _startControl.ui_buttonX_logon.Enabled = true;
                                }
                                else
                                {
                                    Logout();
                                }
                            }
                                ));

                        return;
                    }
                    var loginMsg = new DataAdminMessageFactory.LoginMessage(username, password, 'd');
                    try
                    {
                        _clientService.ServiceProxy.Login(loginMsg);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        MessageBox.Show(ex.Message);
                    }
                }) {Name = "LogonThread", IsBackground = true};

            _logonThread.Start();
        }
Beispiel #56
0
        public void run()
        {
            string[] cmdArgs = Environment.GetCommandLineArgs();
            Console.WriteLine("Manager::run() - arguments are {0}", Environment.CommandLine);
            String paramServer   = "127.0.0.1";
            String paramInstance = "";

            foreach (string arg in cmdArgs)
            {
                Console.WriteLine(" - arg: {0}", arg);
                if (arg.Contains("="))
                {
                    String[] ArgS = arg.Split('=');
                    Console.WriteLine(" -- {0}=>{1}", ArgS[0], ArgS[1]);
                    switch (ArgS[0])
                    {
                    case "server":
                        paramServer = ArgS[1];
                        break;

                    case "instance":
                        paramInstance = ArgS[1];
                        break;

                    default:
                        Console.WriteLine("Unhandled param: {0}", ArgS[0]);
                        break;
                    }
                }
            }
            pluginInst = new HSPI(paramInstance);

            //Environment.CommandLine.
            client   = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);
            clientCB = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);

            try
            {
                client.Connect();
                clientCB.Connect();
                hsHost = client.ServiceProxy;
                double ApiVer = hsHost.APIVersion;
                Console.WriteLine("Host ApiVersion : {0}", ApiVer);
                hsHostCB = clientCB.ServiceProxy;
                ApiVer   = hsHostCB.APIVersion;
                Console.WriteLine("Host CB ApiVersion : {0}", ApiVer);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot start instance because of : {0}", e.Message);
                return;
            }
            Console.WriteLine("Connection to HS succeeded!");
            try
            {
                pluginInst.hsHost   = hsHost;
                pluginInst.hsHostCB = hsHostCB;
                hsHost.Connect(pluginInst.Name, "");
                Console.WriteLine("Connected, waiting to be initialized...");
                do
                {
                    Thread.Sleep(500);
                } while (client.CommunicationState == CommunicationStates.Connected && pluginInst.Running);

                Console.WriteLine("Connection lost, exiting");
                pluginInst.Running = false;

                client.Disconnect();
                clientCB.Disconnect();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to host connect: {0}", e.Message);
                return;
            }

            Console.WriteLine("Exiting!!!");
        }
Beispiel #57
0
 /// <summary>
 /// Creates a new ChatClient object.
 /// </summary>
 /// <param name="client">Scs client reference</param>
 /// <param name="clientProxy">Proxy object to call remote methods of chat client</param>
 /// <param name="userInfo">User informations of client</param>
 public ChatClient(IScsServiceClient client, IChatClient clientProxy, UserInfo userInfo)
 {
     Client = client;
     ClientProxy = clientProxy;
     User = userInfo;
 }
Beispiel #58
0
 private void GsserviceOnClientConnected(object sender, ServiceClientEventArgs serviceClientEventArgs)
 {
     _authedClient = serviceClientEventArgs.Client;
 }