本文整理汇总了Golang中github.com/gorilla/websocket.Conn.LocalAddr方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.LocalAddr方法的具体用法?Golang Conn.LocalAddr怎么用?Golang Conn.LocalAddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gorilla/websocket.Conn
的用法示例。
在下文中一共展示了Conn.LocalAddr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newClient
func newClient(ws *websocket.Conn, h *hub, srv *wsServer) *wsClient {
if ws == nil {
log.Panicln("ws cannot be nil")
}
if srv == nil {
log.Panicln("server cannot be nil")
}
maxID++
return &wsClient{
id: maxID,
ws: ws,
h: h,
srv: srv,
subs: make(map[string]string),
inMsgChan: make(chan *wsMessage),
outMsgChan: make(chan *wsMessage),
doneChan: make(chan bool),
socketID: sha1Sum(fmt.Sprintf("%s-%s-%d", ws.RemoteAddr().String(),
ws.LocalAddr().String(), maxID)),
}
}
示例2: NewCcusConn
func NewCcusConn(ws *websocket.Conn, cc_in chan updateInfo) *ccusConn {
log.Printf("ws[%s]:new connect %s", ws.RemoteAddr(), ws.LocalAddr())
ws.SetReadDeadline(time.Now().Add(pongWait))
ws.SetWriteDeadline(time.Now().Add(writeWait))
pc := &ccusConn{}
pc.ws = ws
pc.cc_in = cc_in
go pc.receiver()
return pc
}
示例3: NewConnection
func NewConnection(ws *websocket.Conn) (*connection, error) {
var err error
ret := &connection{ws: ws}
err = ws.WriteJSON(&MyNode)
if err == nil {
err = ws.ReadJSON(&ret.node)
}
if err != nil {
return nil, err
}
ret.name = fmt.Sprintf("%s -> %s (%s)", ws.LocalAddr(), ws.RemoteAddr(), ret.node)
ret.sendChan = make(chan interface{}, 1)
go ret.sendLoop()
return ret, nil
}
示例4: handler
func (l *listener) handler(ws *websocket.Conn, req *http.Request) {
l.lock.Lock()
if !l.running {
ws.Close()
l.lock.Unlock()
return
}
if ws.Subprotocol() != l.proto.Name()+".sp.nanomsg.org" {
ws.Close()
l.lock.Unlock()
return
}
w := &wsPipe{ws: ws, addr: l.addr, proto: l.proto, open: true}
w.dtype = websocket.BinaryMessage
w.iswss = l.iswss
w.ws.SetReadLimit(int64(l.maxrx))
w.props = make(map[string]interface{})
w.props[mangos.PropLocalAddr] = ws.LocalAddr()
w.props[mangos.PropRemoteAddr] = ws.RemoteAddr()
if req.TLS != nil {
w.props[mangos.PropTLSConnState] = *req.TLS
}
w.wg.Add(1)
l.pending = append(l.pending, w)
l.cv.Broadcast()
l.lock.Unlock()
// We must not return before the socket is closed, because
// our caller will close the websocket on our return.
w.wg.Wait()
}