第一范文网 - 专业文章范例文档资料分享平台

SuperSocket学习进展

来源:用户分享 时间:2025/5/19 15:32:22 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

{

var session = commandContext.Session;

var startTime = session.Items.GetValue(\ var ts = DateTime.Now.Subtract(startTime);

if (ts.TotalSeconds > 5 && session.Logger.IsInfoEnabled) {

session.Logger.InfoFormat(\commandContext.CurrentCommand.Name, ts.ToString()); } } }

然后通过增加属性的方法给命令 \应用此过滤器: [LogTimeCommandFilter]

public class QUERY : StringCommandBase {

public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) {

//Your code } }

如果你想应用次过滤器给所有的命令, 你可以向下面的代码这样将此命令过滤器的属性加到你的 AppServer 类上面去: [LogTimeCommandFilter]

public class TestServer : AppServer { }

你可以通过将 commandContext's 的 Cancel 属性设为 True 来取消当前命令的执行: public class LoggedInValidationFilter : CommandFilterAttribute {

public override void OnCommandExecuting(CommandExecutingContext commandContext) {

var session = commandContext.Session as MyAppSession;

//If the session is not logged in, cancel the executing of the command if (!session.IsLoggedIn)

commandContext.Cancel = true; }

public override void OnCommandExecuted(CommandExecutingContext commandContext) { } }

ServerConfig配置内没有对ipRange的配置,只有ConnectionFilter属性,但完全不起作用,难道只能使用BootstrapFactory启动才能使用连接过滤吗?

多个 Listener(监听器)

关键字: 多个端口, 多个监听, Listener, 多个Listener

单个 listener

在下面的配置中,你可以配置服务器的监听 ip/port:

serverType=\SuperSocket.QuickStart.TelnetServer_StartByConfig\ ip=\

多个 listener

你可以增加一个子节点 \用于添加多对监听 ip/port:

type=\SuperSocket.QuickStart.EchoService\

在这种情况下,服务器实例将监听两个本地端口。 这个功能和 IIS 站点的多绑定功能非常相似。 你也可以给不同的监听器设置不同的选项:

type=\SuperSocket.QuickStart.EchoService\

搜索更多关于: SuperSocket学习进展 的文档
SuperSocket学习进展.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0a9r10687u9y6yn8bcxl_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top