Ejemplo n.º 1
0
 public Ts3QueryClient(EventDispatchType dispatcherType)
 {
     connecting = false;
     tcpClient  = new TcpClient();
     msgProc    = new SyncMessageProcessor();
     dispatcher = EventDispatcherHelper.Create(dispatcherType);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Dispatches the event invocation.
        /// </summary>
        /// <param name="arguments">
        /// The arguments passed to the listeners.
        /// </param>
        /// <param name="dispatchType">
        /// The event dispatch type.
        /// </param>
        public void Dispatch(EventData arguments, EventDispatchType dispatchType = EventDispatchType.Default)
        {
            if (dispatchType == EventDispatchType.Default)
            {
                dispatchType = _defaultDispatchType;
            }

            switch (dispatchType)
            {
            case EventDispatchType.Now:
                if (_event == null)
                {
                    return;
                }

                _event(arguments);
                break;

            case EventDispatchType.NextFrame:
                _deferredDispatchData.Enqueue(arguments);
                break;

            default:
                throw new InvalidEnumArgumentException("dispatchType", (int)dispatchType, typeof(EventDispatchType));
            }
        }
Ejemplo n.º 3
0
 /// <summary>Creates a new client. A client can manage one connection to a server.</summary>
 /// <param name="dispatcherType">The message processing method for incomming notifications.
 /// See <see cref="EventDispatchType"/> for further information about each type.</param>
 public Ts3FullClient(EventDispatchType dispatcherType)
 {
     status        = Ts3ClientStatus.Disconnected;
     ts3Crypt      = new Ts3Crypt();
     packetHandler = new PacketHandler(ts3Crypt);
     msgProc       = new MessageProcessor(false);
     dispatcher    = EventDispatcherHelper.Create(dispatcherType);
     wasExit       = true;
 }
Ejemplo n.º 4
0
 /// <summary>Creates a new client. A client can manage one connection to a server.</summary>
 /// <param name="dispatcherType">The message processing method for incomming notifications.
 /// See <see cref="EventDispatchType"/> for further information about each type.</param>
 public Ts3FullClient(EventDispatchType dispatcherType)
 {
     status        = Ts3ClientStatus.Disconnected;
     ts3Crypt      = new Ts3Crypt();
     packetHandler = new PacketHandler(ts3Crypt);
     msgProc       = new AsyncMessageProcessor();
     dispatcher    = EventDispatcherHelper.Create(dispatcherType);
     context       = new ConnectionContext {
         WasExit = true
     };
 }
Ejemplo n.º 5
0
        public TS3QueryClient(EventDispatchType dispatcher)
        {
            status    = QueryClientStatus.Disconnected;
            tcpClient = new TcpClient();
            isInQueue = false;

            switch (dispatcher)
            {
            case EventDispatchType.None: EventDispatcher = new NoEventDispatcher(); break;

            case EventDispatchType.CurrentThread: EventDispatcher = new CurrentThreadEventDisptcher(); break;

            case EventDispatchType.DoubleThread: EventDispatcher = new DoubleThreadEventDispatcher(); break;

            case EventDispatchType.AutoThreadPooled: throw new NotSupportedException();          //break;

            case EventDispatchType.NewThreadEach: throw new NotSupportedException();             //break;

            default: throw new NotSupportedException();
            }
        }
Ejemplo n.º 6
0
        public static IEventDispatcher Create(EventDispatchType dispatcherType)
        {
            IEventDispatcher dispatcher;

            switch (dispatcherType)
            {
            case EventDispatchType.None: dispatcher = new NoEventDispatcher(); break;

            case EventDispatchType.CurrentThread: dispatcher = new CurrentThreadEventDisptcher(); break;

            case EventDispatchType.ExtraDispatchThread: dispatcher = new ExtraThreadEventDispatcher(); break;

            case EventDispatchType.DoubleThread: throw new NotSupportedException();             //break;

            case EventDispatchType.AutoThreadPooled: dispatcher = new AutoThreadPooledEventDispatcher(); break;

            case EventDispatchType.NewThreadEach: throw new NotSupportedException();             //break;

            default: throw new NotSupportedException();
            }
            return(dispatcher);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnvoyEventBase"/> class.
 /// </summary>
 /// <param name="defaultDispatchType">
 /// The default dispatch type.
 /// </param>
 protected EnvoyEventBase(EventDispatchType defaultDispatchType = EventDispatchType.Default)
 {
     _defaultDispatchType = defaultDispatchType == EventDispatchType.Default ?
                            EventDispatchType.Now :
                            defaultDispatchType;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultDispatchTypeAttribute"/> class.
 /// </summary>
 /// <param name="dispatchType">
 /// Default dispatch type that will be used for an event.
 /// </param>
 public DefaultDispatchTypeAttribute(EventDispatchType dispatchType)
 {
     DispatchType = dispatchType;
 }
Ejemplo n.º 9
0
 public Ts3QueryClient(EventDispatchType dispatcherType)
 {
     tcpClient  = new TcpClient();
     msgProc    = new MessageProcessor(true);
     dispatcher = EventDispatcherHelper.Create(dispatcherType);
 }
Ejemplo n.º 10
0
        private void DispatchInternal <T>(T eventData, EventDispatchType dispatchType) where T : EventData
        {
            EventInfo eventInfo = GetEvent <T>();

            eventInfo.EnvoyEvent.Dispatch(eventData, dispatchType);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Dispatches the event invocation.
 /// </summary>
 /// <param name="eventData">
 /// The arguments passed to the listeners.
 /// </param>
 /// <param name="dispatchType">
 /// The event dispatch type.
 /// </param>
 /// <typeparam name="T">
 /// The type of event to dispatch.
 /// </typeparam>
 public void Dispatch <T>(T eventData, EventDispatchType dispatchType = EventDispatchType.Default) where T : EventData
 {
     DispatchInternal(eventData, dispatchType);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Dispatches the event invocation.
 /// </summary>
 /// <param name="dispatchType">
 /// The event dispatch type.
 /// </param>
 /// <typeparam name="T">
 /// The type of event to dispatch.
 /// </typeparam>
 public void Dispatch <T>(EventDispatchType dispatchType = EventDispatchType.Default) where T : EventData
 {
     DispatchInternal <T>(null, dispatchType);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 分发消息
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="data"></param>
 public void DispatchEvent(EventDispatchType eventType, object data = null)
 {
     EventListener?.Invoke(this, new EventArgs(eventType, data));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnvoyEvent"/> class.
 /// </summary>
 /// <param name="defaultDispatchType">
 /// The default event dispatch type.
 /// </param>
 public EnvoyEvent(EventDispatchType defaultDispatchType = EventDispatchType.Default)
     : base(defaultDispatchType)
 {
 }
Ejemplo n.º 15
0
    public EventDispatchType eventType;      // 事件类型

    public EventArgs(EventDispatchType eventType, params object[] data)
    {
        this.data      = data;
        this.eventType = eventType;
    }