private void SshClientOnConnectionStatusChange(CiscoSshClient client, SshClientStatus status)
        {
            switch (status)
            {
            case SshClientStatus.Connected:
                Debug.WriteSuccess("CODEC CONNECTED");
                OnDeviceCommunicatingChange(this, true);
                break;

            case SshClientStatus.Disconnected:
                OnDeviceCommunicatingChange(this, false);
                _initialized = false;
                break;
            }
        }
Beispiel #2
0
        protected virtual void OnConnectionStatusChange(CiscoSshClient client, SshClientStatus status)
        {
            var handler = ConnectionStatusChange;

            if (handler != null)
            {
                try
                {
                    handler(client, status);
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e);
                }
            }
        }
        public CiscoTelePresenceCodec(string address, string username, string password)
        {
            DisableAutoSleepOnStopPlaying = false;
            _deviceAddressString          = address;
            _calls                             = new Calls(this);
            _systemUnit                        = new SystemUnit.SystemUnit(this);
            _cameras                           = new Cameras.Cameras(this);
            _standby                           = new Standby(this);
            _phonebook                         = new Phonebook.Phonebook(this);
            _bookings                          = new Bookings.Bookings(this);
            _audio                             = new Audio.Audio(this);
            _sip                               = new SIP.SIP(this);
            _roomAnalytics                     = new RoomAnalytics.RoomAnalytics(this);
            _video                             = new Video.Video(this);
            _callHistory                       = new CallHistory.CallHistory(this);
            _network[1]                        = new Network.Network(this, 1);
            _networkServices                   = new NetworkServices(this);
            _userInterface                     = new UserInterface.UserInterface(this);
            _diagnostics                       = new Diagnostics.Diagnostics(this);
            _conference                        = new Conference.Conference(this);
            _capabilities                      = new Capabilities.Capabilities(this);
            _sshClient                         = new CiscoSshClient(_deviceAddressString, username, password);
            _sshClient.ReceivedData           += SshClientOnReceivedData;
            _sshClient.ConnectionStatusChange += SshClientOnConnectionStatusChange;
            _httpsClient                       = new HttpsClient(address, username, password);

#if DEBUG
            CrestronConsole.AddNewConsoleCommand(Send,
                                                 "codecsend", "Send a codec xCommand",
                                                 ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(parameters =>
                                                 Send(string.Format("xCommand {0}", parameters)),
                                                 "xCommand", "Send a codec xCommand",
                                                 ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(parameters =>
                                                 Calls.DialNumber(parameters, (code, description, call) =>
            {
            }),
                                                 "Dial", "Dial a number",
                                                 ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(parameters => Send("xStatus"),
                                                 "CodecStatus", "Get the full status of the codec",
                                                 ConsoleAccessLevelEnum.AccessOperator);
#endif
        }
Beispiel #4
0
 protected virtual void OnReceivedData(CiscoSshClient client, ReceivedDataType type, string data)
 {
     try
     {
         var handler = ReceivedData;
         if (handler != null)
         {
             handler(client, new CodecSshClientReceivedDataArgs()
             {
                 DataType       = type,
                 DataAsReceived = data,
                 Lines          = Regex.Split(data, "\r\n|\r|\n")
             });
         }
     }
     catch (Exception e)
     {
         CloudLog.Exception(e);
     }
 }
        private void SshClientOnReceivedData(CiscoSshClient client, CodecSshClientReceivedDataArgs args)
        {
            var matches = Regex.Matches(args.DataAsReceived,
                                        @"\*\w ([^\r\n\""\:]+) (\w+)?(?:\(([\w\=]+)\))?:? ?\""?([^\r\n\""]+)?\""?");

            if (matches.Count <= 0)
            {
                return;
            }

            switch (args.DataType)
            {
            case ReceivedDataType.Configuration:
                foreach (Match configMatch in matches)
                {
                    try
                    {
                        OnConfigurationChanged(this, new ConfigurationChangeEventArgs
                        {
                            Path         = configMatch.Groups[1].Value,
                            PropertyName = configMatch.Groups[2].Value,
                            Value        = configMatch.Groups[4].Value
                        });
                    }
                    catch (Exception e)
                    {
                        CloudLog.Exception(e);
                    }
                }
                break;

            case ReceivedDataType.Status:
                OnStatusReceived((from Match statusMatch in matches
                                  select new StatusUpdateItem(statusMatch))
                                 .ToArray());
                if (_initialized)
                {
                    return;
                }
                CloudLog.Notice("{0} Initialized OK", this);
                _initialized = true;
                break;

            case ReceivedDataType.Event:
                var items = new Dictionary <string, Dictionary <string, string> >();
                foreach (Match eventMatch in matches)
                {
                    if (!items.ContainsKey(eventMatch.Groups[1].Value))
                    {
                        items.Add(eventMatch.Groups[1].Value, new Dictionary <string, string>());
                    }

                    if (eventMatch.Groups[4].Success)
                    {
                        items[eventMatch.Groups[1].Value][eventMatch.Groups[2].Value] = eventMatch.Groups[4].Value;
                    }
                    else
                    {
                        items[eventMatch.Groups[1].Value][eventMatch.Groups[2].Value] = string.Empty;
                    }
                }

                foreach (var item in items)
                {
                    OnEventReceived(item.Key, item.Value);
                }
                break;

            case ReceivedDataType.Response:
                foreach (Match response in matches)
                {
#if DEBUG
                    Debug.WriteInfo("Response", "{0} {1} {2}",
                                    response.Groups[1].Value,
                                    response.Groups[2].Value,
                                    response.Groups[3].Value);
#endif
                }
                break;
            }
        }