当前位置: 首页>>代码示例>>Golang>>正文


Golang Conn.LocalAddr方法代码示例

本文整理汇总了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)),
	}
}
开发者ID:joshk,项目名称:hustle,代码行数:26,代码来源:ws_client.go

示例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
}
开发者ID:semantic-machines,项目名称:veda,代码行数:12,代码来源:preparer.go

示例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
}
开发者ID:peak6,项目名称:gmap,代码行数:18,代码来源:gmap.go

示例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()
}
开发者ID:kildevaeld,项目名称:projects,代码行数:37,代码来源:ws.go


注:本文中的github.com/gorilla/websocket.Conn.LocalAddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。