/// <summary> /// IClieventListener.EventReceive /// 처리흐름 : ClientIoHandler -> [IClientEventListener] -> ClientEventAbstract -> IUIEventListener /// </summary> /// <param name="protocol"></param> /// <param name="buffer"></param> public void EventReceive(Protocol protocol, IoBuffer buffer) { Log.game.Debug("controller.EventReceived : " + protocol.Desc); //프로토콜에 해당하는 ClientEvent 반환 ClientEventAbstract clientEvent = ClientEventFactory.getEvent(protocol); if( clientEvent == null ) return; try{ //이벤트 처리 clientEvent.Set(buffer); }catch{ }finally{ //UIEventListener에 전달하기 위해 등록 AddClientEvent(clientEvent); } }
/// <summary> /// UI 리스너 제외 /// </summary> /// <param name="protocol"></param> /// <param name="listener"></param> public void RemoveUIListener(Protocol protocol, IUIEventListener listener) { lock( listenerLock ) { copyListeners.AddRange(uiListeners); foreach( UIListenerData data in copyListeners ) { if( data.Protocol != protocol ) continue; if( data.Listener == listener ) { uiListeners.Remove(data); } } copyListeners.Clear(); } }
public UIListenerData(Protocol protocol, IUIEventListener listener) { this.Protocol = protocol; this.Listener = listener; }
/// <summary> /// UI 리스너 등록 /// </summary> /// <param name="protocol"></param> /// <param name="listener"></param> public void AddUIListener(Protocol protocol, IUIEventListener listener) { lock( listenerLock ) { uiListeners.Add(new UIListenerData(protocol, listener)); } }
/// <summary> /// 프로토콜에 해당하는 ClientEvent 반환 /// </summary> public static ClientEventAbstract getEvent(Protocol protocol) { if( protocol == Protocol.USER_LOGIN ) return new PUserLogin(); if( protocol == Protocol.DUPLICATE_LOGIN ) return new PDuplicateLogin(); return null; }