Esempio n. 1
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 public static ServerServiceDefinition BindService(MessengerBase serviceImpl)
 {
     return(ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Login, serviceImpl.Login)
            .AddMethod(__Method_SendTextMessage, serviceImpl.SendTextMessage)
            .AddMethod(__Method_RequestPendingMessages, serviceImpl.RequestPendingMessages).Build());
 }
        /// <summary>
        /// Iterates device config and adds messengers as neede for each device type
        /// </summary>
        void SetupDeviceMessengers()
        {
            try
            {
                foreach (var device in ConfigReader.ConfigObject.Devices)
                {
                    if (device.Group.Equals("simplmessenger"))
                    {
                        var props = JsonConvert.DeserializeObject <SimplMessengerPropertiesConfig>(device.Properties.ToString());

                        var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key);

                        if (DeviceManager.GetDeviceForKey(messengerKey) != null)
                        {
                            Debug.Console(2, this, "Messenger with key: {0} already exists. Skipping...", messengerKey);
                            continue;
                        }

                        var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey);

                        if (dev == null)
                        {
                            Debug.Console(1, this, "Unable to find device config for key: '{0}'", props.DeviceKey);
                            continue;
                        }

                        var           type      = device.Type.ToLower();
                        MessengerBase messenger = null;

                        if (type.Equals("simplcameramessenger"))
                        {
                            Debug.Console(2, this, "Adding SIMPLCameraMessenger for: '{0}'", props.DeviceKey);
                            messenger = new SIMPLCameraMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart);
                        }
                        else if (type.Equals("simplroutemessenger"))
                        {
                            Debug.Console(2, this, "Adding SIMPLRouteMessenger for: '{0}'", props.DeviceKey);
                            messenger = new SIMPLRouteMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart);
                        }

                        if (messenger != null)
                        {
                            DeviceManager.AddDevice(messenger);
                            messenger.RegisterWithAppServer(Parent);
                        }
                        else
                        {
                            Debug.Console(2, this, "Unable to add messenger for device: '{0}' of type: '{1}'", props.DeviceKey, type);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Console(2, this, "Error Setting up Device Managers: {0}", e);
            }
        }
Esempio n. 3
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, MessengerBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Message, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Messaging.MessageRequest, global::Messaging.MessageResponse>(serviceImpl.Message));
 }
Esempio n. 4
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(MessengerBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Message, serviceImpl.Message).Build());
 }
Esempio n. 5
0
 public MessengerBridge(MessengerBase m)
 {
     _mb = m;
 }