public void RemoveSession(LazynetHandlerContext ctx) { string address = ctx.GetAddress(); string id = EncryptionHelper.GetMD5Hash(address); this.SessionManager.RemoveSession(id); }
public LazynetSession GetSessionByCtx(LazynetHandlerContext ctx) { string address = ctx.GetAddress(); string id = EncryptionHelper.GetMD5Hash(address); return(this.SessionManager.GetSession(id)); }
public void Read(LazynetHandlerContext ctx, string msg) { this.Context.Log(LazynetLogLevel.Debug, "===recv data is " + msg); var message = SerializeHelper.Deserialize <LazynetMessage>(msg); this.CallService(ctx, message); }
public void DisConnect(LazynetHandlerContext ctx) { this.CallService(ctx, new LazynetMessage() { RouteUrl = "/System/DisConnect", Parameters = null }); }
public void Read(LazynetHandlerContext ctx, string msg) { this.Context.Log(LazynetLogLevel.Debug, "===recv data is " + msg); var message = SerializeHelper.Deserialize <LazynetMessage>(msg); message.Parameters.Insert(0, ctx); this.Context.Call(message); }
public void Exception(LazynetHandlerContext ctx, Exception exception) { this.CallService(ctx, new LazynetMessage() { RouteUrl = "/System/Exception", Parameters = new List <object> { exception } }); }
public void AddNode(string name, LazynetHandlerContext ctx) { if (string.IsNullOrEmpty(name) || ctx == null) { this.Logger.Error(" name is empty or ctx is null, so add node fail "); return; } this.Nodes.Add(name, ctx); }
public void SendMessage(LazynetHandlerContext ctx, string routeUrl, LuaTable args) { LazynetMessage message = new LazynetMessage(); message.RouteUrl = routeUrl; foreach (var item in args) { message.Parameters.Add(item.Value); } ctx.WriteAndFlushAsync(SerializeHelper.Serialize(message)); }
public void DisConnect(LazynetHandlerContext ctx) { this.CallService(new LazynetMessage() { RouteUrl = "/System/DisConnect", Parameters = new List <object>() { ctx } }); }
public void DisConnect(LazynetHandlerContext ctx) { this.Context.Call(new LazynetMessage() { RouteUrl = LazynetActionConstant.NodeDisconnect, Parameters = new List <object>() { ctx } }); }
public void Exception(LazynetHandlerContext ctx, Exception ex) { this.Context.CallAction(new LazynetMessage() { RouteUrl = "/InteriorServer/Exception", Parameters = new List <object>() { ctx } }); }
public void DisConnect(LazynetHandlerContext ctx) { this.Context.CallAction(new LazynetMessage() { RouteUrl = "/ExternalServer/DisConnect", Parameters = new List <object>() { ctx } }); }
public void Exception(LazynetHandlerContext ctx, Exception ex) { this.Context.CallAction(new LazynetMessage() { RouteUrl = "/ExternalServer/Exception", Parameters = new List <object>() { ctx, ex.ToString() } }); }
public void Exception(LazynetHandlerContext ctx, Exception exception) { this.Context.Call(new LazynetMessage() { RouteUrl = LazynetActionConstant.NodeException, Parameters = new List <object>() { ctx, exception.ToString() } }); }
public void AddSession(LazynetHandlerContext ctx) { string address = ctx.GetAddress(); string id = EncryptionHelper.GetMD5Hash(address); this.SessionDict.Add(id, new LazynetSession() { Address = address, ID = id, ConnectDateTime = DateTime.Now, Context = ctx }); }
public void Read(LazynetHandlerContext ctx, string msg) { var sessionMessage = SerializeHelper.Deserialize <LazynetSessionMessage>(msg); var message = new LazynetMessage(); message.RouteUrl = "/ExternalServer/Read"; message.Parameters = new List <object>() { ctx, sessionMessage.ServerName, sessionMessage.RouteUrl, }; message.Parameters.AddRange(sessionMessage.Parameters); this.Context.CallAction(message); }
public void Read(LazynetHandlerContext ctx, string msg) { // 转发消息 var message = SerializeHelper.Deserialize <LazynetMessage>(msg); var messageWrapper = new LazynetMessage(); messageWrapper.RouteUrl = "/InteriorServer/Read"; messageWrapper.Parameters = new List <object>(); messageWrapper.Parameters.Add(ctx); messageWrapper.Parameters.Add(message.RouteUrl); foreach (var item in message.Parameters) { messageWrapper.Parameters.Add(item); } this.Context.CallAction(messageWrapper); }
public void Add(string name, LazynetHandlerContext ctx) { var findNode = this.Nodes .Where(it => it.Name == name) .FirstOrDefault(); if (findNode == null) { this.Nodes.Add(new LazynetNode() { Address = ctx.GetAddress(), ConnectDateTime = DateTime.Now, Context = ctx, ID = EncryptionHelper.GetMD5Hash(ctx.GetAddress()), Name = name }); } }
private void CallService(LazynetHandlerContext ctx, LazynetMessage message) { try { this.Context.CurrentContext = ctx; Stopwatch sw = new Stopwatch(); sw.Start(); this.Context.ActionProxy.Call(message); sw.Stop(); if (sw.Elapsed.TotalSeconds >= 3) { this.Context.Log(LazynetLogLevel.Warn, message.RouteUrl + " action run slow "); } } catch (Exception ex) { this.Context.Log(LazynetLogLevel.Error, ex.ToString()); } }
public void SendMessage(LazynetHandlerContext ctx, string routeUrl, LuaTable args) { if (ctx == null) { var method = new StackFrame(1).GetMethod(); this.Log(LazynetLogLevel.Warn, method.Name + ": ctx is null "); return; } LazynetMessage message = new LazynetMessage(); message.RouteUrl = routeUrl; foreach (var item in args) { message.Parameters.Add(item.Value); } string msg = SerializeHelper.Serialize(message); this.Log(LazynetLogLevel.Debug, "===send data is " + msg); ctx.WriteAndFlushAsync(msg); }
public void AddSession(LazynetHandlerContext ctx) { this.SessionManager.AddSession(ctx); }
public void RemoveNode(LazynetHandlerContext ctx) { string id = EncryptionHelper.GetMD5Hash(ctx.GetAddress()); this.Nodes.RemoveByID(id); }