Exemplo n.º 1
0
        public void ExecuteUserOptionsCommand()
        {
            if (!userOptionsReceived)
            {
                ConnectionStatus         = "Requesting options from CMS service...";
                IsAuthenticationRequired = false;
            }


            Services.ConnectionManager manager = new Services.ConnectionManager();

            var login = new StubLoginInfo
            {
                Hostname = HostName,
                Security = 0,
                Port     = PortNumber
            };

            manager.GetUserOptions(login,
                                   (state, options) =>
            {
                App.Current.Dispatcher.BeginInvokeOnMainThread(new Action(() => UserOptionsRetrieved(state, options, manager)));
            });
        }
        //HostName, Username, password, PortNumber, SelectedGroup)
        public bool Connect(string hostname, string username, string password, ushort portNumber, Symbol groupID, string locale)
        {
            IsConnected = false;


            var logonInfo = new StubLoginInfo
            {
                Hostname = hostname,
                //Hostname = User specified hostname,
                Port = portNumber,
                //Port = 1338,
                Security = TransportSecurity.Insecure,
                //Security = 0,
                UserName = username,
                GroupID  = groupID,
                Locale   = locale
                           //GroupID = Symbol.Intern("Pdmusers")
            };

            LoginInfo = logonInfo;

            var client = new TcpMessageClient(
                hostname,
                portNumber,
                TransportSecurity.Insecure);

            lock (this.interlock)
                this.client = client;

            // insert logging between stub and client
            BidiSharedPipe shared = new BidiSharedPipe();

            if (this.LogMessage != null)
            {
                shared.Send.MessageReceived += new LogPipe("sent", this.LogMessage).PostMessage;
                shared.Recv.MessageReceived += new LogPipe("recv", this.LogMessage).PostMessage;
            }

            shared.Send.MessageReceived += client.SendPipe.PostMessage;

            client.ReceivePipe = shared.Recv;

            shared.Recv.PipeDropped += OnConnectionDropped;

            client.StartReceiving();

            // create a stub system interface and get back some IDL
            Message idl;

            var connectSettings = new ConnectSettings
            {
                Client          = shared,
                Secret          = password,
                UiClientVersion = appVersion,
                ClientType      = "SSEClientUi"
            };

            var systemInterface = SystemInterfaceStub.Connect(connectSettings, logonInfo, out idl);

            lock (this.interlock)
            {
                idl.Extract(Symbol.Intern("GroupID"), out this.groupID);
                this.systemInterface = systemInterface;
                _idl        = idl;
                IsConnected = true;
            }

            sessionId_   = client.SessionId;
            remIPAddress = connectSettings.remIPAddress; // this session as seen by remote
            remPort      = connectSettings.remPort;      // this session as seen by remote
            return(IsConnected);
        }