12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using CommonLang.Log;
- using CommonLang.Protocol;
- using CommonNetwork_ICE.Client;
- using CommonNetwork_ICE.Common;
- using CommonNetwork_ICE.Session;
- using CommonNetwork_ICE.Util;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CommonNetwork_ICE.handler
- {
- class TcpServerCallbackImpl : Slice.ServerCallbackDisp_
- {
- private static Logger log = LoggerFactory.GetLogger("TcpServerCallbackImpl");
- private IceClientNetSession session;
- private IceMessageCodec codec;
- public TcpServerCallbackImpl(IceMessageCodec codec, IceClientNetSession session)
- {
- this.codec = codec;
- this.session = session;
- }
- public override void ServerToClient(Slice.TransMessage message, Ice.Current current__)
- {
- // 数据解码
- IMessage imessage = null;
- try
- {
- codec.doDecode(message, out imessage);
- }
- catch (Exception e)
- {
- Env.ENV_ERR_CODE = Error.ERR_CODE_4;
- session.onException(e);
- return;
- }
- if (imessage == null)
- {
- return;
- }
- // 数据处理
- try
- {
- long startTickCount = Environment.TickCount;
- session.onReceive(imessage, message.length);
- long endTickCount = Environment.TickCount;
- long interval = endTickCount - startTickCount;
- if (interval > Env.MSG_PROC_TIME_OUT)
- {
- log.Info("客户端消息处理超时,用时【" + interval + "】,消息编号【" + imessage.GetType() + "】");
- }
- }
- catch (Exception e)
- {
- log.Error(e.Message);
- Env.ENV_ERR_CODE = Error.ERR_CODE_5;
- session.onException(e);
- }
- }
- }
- }
|