Exemplo 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;
                    }
                }
            }
        }
Exemplo n.º 2
0
 internal static extern void Server_SetMethodHandler(NativeServer server, ChatMethod func);