nanomsg.org/go/mangos/v2@v2.0.9-0.20200203084354-8a092611e461/transport/wss/wss.go (about)

     1  // Copyright 2018 The Mangos Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use file except in compliance with the License.
     5  // You may obtain a copy of the license at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package wss implements a secure WebSocket transport for mangos.
    16  // To enable it simply import it.
    17  package wss
    18  
    19  import (
    20  	"nanomsg.org/go/mangos/v2"
    21  	"nanomsg.org/go/mangos/v2/transport"
    22  	"nanomsg.org/go/mangos/v2/transport/ws"
    23  )
    24  
    25  type wssTran int
    26  
    27  // Transport is a transport.Transport for WebSocket over TLS.
    28  const Transport = wssTran(0)
    29  
    30  func init() {
    31  	transport.RegisterTransport(Transport)
    32  }
    33  
    34  func (wssTran) Scheme() string {
    35  	return "wss"
    36  }
    37  
    38  func (w wssTran) NewDialer(addr string, sock mangos.Socket) (transport.Dialer, error) {
    39  	return ws.Transport.NewDialer(addr, sock)
    40  }
    41  
    42  func (w wssTran) NewListener(addr string, sock mangos.Socket) (transport.Listener, error) {
    43  	return ws.Transport.NewListener(addr, sock)
    44  }