當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。