コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 internal void Init()
 {
     _context = new ChannelContext();
     if (OnRequested != null)
     {
         _context.OnRequested += new RequestHandle(OnRequested);
     }
     if (OnCallRemote != null)
     {
         _context.OnCallRemote += new CallRemoteHandle(OnCallRemote);
     }
     if (OnClosing != null)
     {
         _context.OnClosed += new ClosingHandle(OnClosing);
     }
     if (OnSocketClosed != null)
     {
         _context.OnSocketClosed += new ClosingHandle(OnSocketClosed);
     }
 }
コード例 #2
0
 private bool NotifyChannelReceive(ChannelContext context, string param, byte[] buffer)
 {
     //并发
     lock (_instance)
     {
         if (context != null && context.IsConnect)
         {
             try
             {
                 var callback = context.GetCallback();
                 if (callback == null)
                 {
                     return false;
                 }
                 callback.Receive(param, buffer);
                 return true;
             }
             catch (Exception ex)
             {
                 context.IsClosed = true;
                 TraceLog.WriteError("Notify:{0} {1}", param, ex);
             }
         }
     }
     return false;
 }
コード例 #3
0
 /// <summary>
 /// 
 /// </summary>
 internal void Init()
 {
     _context = new ChannelContext();
     if (OnRequested != null)
         _context.OnRequested += new RequestHandle(OnRequested);
     if (OnCallRemote != null)
         _context.OnCallRemote += new CallRemoteHandle(OnCallRemote);
     if (OnClosing != null)
         _context.OnClosed += new ClosingHandle(OnClosing);
     if (OnSocketClosed != null)
         _context.OnSocketClosed += new ClosingHandle(OnSocketClosed);
 }
コード例 #4
0
ファイル: GameHostApp.cs プロジェクト: rongxiong/Scut
 protected override void OnSocketClosed(ChannelContext context, string remoteaddress)
 {
 }
コード例 #5
0
ファイル: GameHost.cs プロジェクト: rongxiong/Scut
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 /// <param name="param"></param>
 /// <param name="remoteAddress"></param>
 /// <returns></returns>
 private byte[] OnRequestComplated(ChannelContext context, string param, string remoteAddress)
 {
     lock (context)
     {
         SocketGameResponse response = new SocketGameResponse();
         HttpGet httpGet = new HttpGet(param, remoteAddress);
         OnRequested(httpGet, response);
         return response.ReadByte();
     }
 }
コード例 #6
0
ファイル: GameHost.cs プロジェクト: rongxiong/Scut
 protected abstract void OnSocketClosed(ChannelContext context, string remoteaddress);
コード例 #7
0
ファイル: GameHost.cs プロジェクト: rongxiong/Scut
 protected byte[] OnCallRemoteComplated(ChannelContext context, string route, string param, string remoteAddress)
 {
     lock (context)
     {
         HttpGet httpGet = new HttpGet(param, remoteAddress);
         MessageStructure structure = new MessageStructure();
         MessageHead head = new MessageHead();
         OnCallRemote(route, httpGet, head, structure);
         structure.WriteBuffer(head);
         return structure.ReadBuffer();
     }
 }