1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonNetwork.Sockets;
- using CommonLang.Protocol;
- using RoomService.Net.BsServer;
- using CommonLang.Log;
- using RoomService.Net.BsClient;
- using CommonAI.ZoneClient;
- using CommonAI.Zone;
- using CommonLang.IO;
- using CommonAI.Zone.ZoneEditor;
- using CommonAI.ZoneServer;
- using CommonLang.Concurrent;
- using CommonNetwork.Net;
- using CommonLang.Property;
- using CommonAIClient;
- using CommonAI;
- namespace CommonAIClient.Client
- {
- public class BattleClientDirect : BattleClient, INetSessionListener
- {
- private static Logger log = LoggerFactory.GetLogger("BattleClientDirect");
- private INetSession session;
- public override INetSession Session { get { return session; } }
- public BattleClientDirect(
- EditorTemplates data_root,
- MessageFactoryGenerator msgFactory,
- PlayerWillConnectResponseB2R room,
- PlayerWillConnectRequestR2B testToken,
- string token)
- : base(data_root, msgFactory, room, testToken, token)
- {
- INetSession netSession = ReflectionUtil.CreateInterface<INetSession>(room.Room.NetDriverString);
- if (netSession == null)
- {
- throw new Exception("Invalid NetDriver : " + room.Room.NetDriverString);
- }
- this.session = netSession;
- }
- protected override void Disposing()
- {
- this.Stop();
- base.Disposing();
- }
- public override void Start()
- {
- session.Open(room.Room.ClientConnectString, new SynchronizedBattleCodec(base.DataRoot.Templates), this);
- }
- public override void Stop()
- {
- session.Close();
- }
- //----------------------------------------------------------------------------------------------------
- void INetSessionListener.sessionOpened(INetSession session)
- {
- base.callback_sessionOpened(session);
- }
- void INetSessionListener.sessionClosed(INetSession session)
- {
- base.callback_sessionClosed(session);
- }
- void INetSessionListener.messageReceived(INetSession session, object data)
- {
- base.callback_messageReceived(session, data);
- }
- void INetSessionListener.messageSent(INetSession session, object data)
- {
- base.callback_messageSent(session, data);
- }
- void INetSessionListener.onError(INetSession session, Exception err)
- {
- base.callback_onError(session, err);
- }
- }
- }
|