V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
ryanking8215
V2EX  ›  Go 编程语言

go.net.websocket的设计问题

  •  
  •   ryanking8215 ·
    ryanking8215 · 2013-11-01 21:18:18 +08:00 · 1438 次点击
    这是一个创建于 3821 天前的主题,其中的信息可能已经有所发展或是发生改变。
    websocket设计用了type Handle func(*conn),即一个函数回调来处理websocket的连接,conn即websocket.conn,是type struct。函数回调的参数即指向了这个conn的一个指针。

    那如果我需要自己的MyWebscoketConn呢?这个要怎么破呢?


    反观像net.Dial和net.TcpListener,处理的都是net.conn,是一个type interface。有TcpConn实现了该interface,如果要设计自己的MyTcpConn,只要在MyTcpConn里mixin TcpConn就行了。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5633 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 623ms · UTC 02:03 · PVG 10:03 · LAX 19:03 · JFK 22:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.