Ejemplo n.º 1
0
        /// <summary>
        /// Sets signals and methods handlers and register all the methods and events
        /// </summary>
        private void InitializeHandlers()
        {
            _chatMethod = new ChatMethod(this.ManageMethodCall);
            _chatSignal = new ChatSignal(this.ManageSignalCall);
            NativeHelper.Server_SetMethodHandler(_nativeServer.Value, _chatMethod);
            NativeHelper.Server_SetSignalHandler(_nativeServer.Value, _chatSignal);

            // Methods initialization
            Type type = typeof(T);

            MethodInfo[] methodInfos = type.GetMethods();
            foreach (MethodInfo mInfo in methodInfos)
            {
                Console.WriteLine(mInfo.Name);
                object[] attributes = mInfo.GetCustomAttributes(false);
                foreach (object attribute in attributes)
                {
                    if (attribute is RemoteMethodAttribute)
                    {
                        Console.WriteLine("METHOD NAME = {0}", mInfo.Name);
                        NativeHelper.Server_RegisterMethodHandler(_nativeServer.Value, mInfo.Name);
                        break;
                    }
                }
            }
            // Events initialization
            EventInfo[] eInfos = type.GetEvents();
            foreach (EventInfo eInfo in eInfos)
            {
                Console.WriteLine(eInfo.Name);
                object[] attributes = eInfo.GetCustomAttributes(false);
                foreach (object attribute in attributes)
                {
                    if (attribute is RemoteEventAttribute)
                    {
                        Console.WriteLine("EVENT NAME  = {0}", eInfo.Name);

                        NativeHelper.Server_RegisterSignalHandler(_nativeServer.Value, eInfo.Name);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize the handlers used by the C++ dll to handle the signals
        /// </summary>
        private void InitializeHandlers()
        {
            _eventHandler = new ChatSignal(this.ManageSignalCall);
            NativeHelper.Client_SetSignalHandler(_nativeClient.Value, _eventHandler);

            Type type = typeof(T);

            EventInfo[] eInfos = type.GetEvents();
            foreach (EventInfo eInfo in eInfos)
            {
                object[] attributes = eInfo.GetCustomAttributes(false);
                foreach (object attribute in attributes)
                {
                    if (attribute is RemoteEventAttribute)
                    {
                        NativeHelper.Client_RegisterSignalHandler(_nativeClient.Value, eInfo.Name);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 internal static extern void Client_SetSignalHandler(NativeClient client, ChatSignal func);
Ejemplo n.º 4
0
 internal static extern void Server_SetSignalHandler(NativeServer server, ChatSignal func);