github.com/gdamore/mangos@v1.4.0/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  // This transport is considered EXPERIMENTAL.
    17  package wss
    18  
    19  import (
    20  	"nanomsg.org/go-mangos"
    21  	"nanomsg.org/go-mangos/transport/ws"
    22  )
    23  
    24  type wssTran struct {
    25  	w mangos.Transport
    26  }
    27  
    28  func (wssTran) Scheme() string {
    29  	return "wss"
    30  }
    31  
    32  func (w *wssTran) NewDialer(addr string, sock mangos.Socket) (mangos.PipeDialer, error) {
    33  	return w.w.NewDialer(addr, sock)
    34  }
    35  
    36  func (w *wssTran) NewListener(addr string, sock mangos.Socket) (mangos.PipeListener, error) {
    37  	return w.w.NewListener(addr, sock)
    38  }
    39  
    40  // NewTransport allocates a new wss:// transport.
    41  func NewTransport() mangos.Transport {
    42  	w := &wssTran{w: ws.NewTransport()}
    43  	return w
    44  }