Add methods to run protocol over external sockets & listeners
The ServeListener and ConnectOpen methods take an active Listener or Conn respectively, instead of creating their own.
This commit is contained in:
parent
bfe5b74364
commit
f6d6991f46
|
@ -39,6 +39,10 @@ func (r *Ricochet) Connect(host string) (*OpenConnection, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return r.ConnectOpen(conn, host)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Ricochet) ConnectOpen(conn net.Conn, host string) (*OpenConnection, error) {
|
||||||
oc, err := r.negotiateVersion(conn, true)
|
oc, err := r.negotiateVersion(conn, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -56,6 +60,10 @@ func (r *Ricochet) Server(service RicochetService, port int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.ServeListener(service, ln)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Ricochet) ServeListener(service RicochetService, ln net.Listener) {
|
||||||
go r.ProcessMessages(service)
|
go r.ProcessMessages(service)
|
||||||
service.OnReady()
|
service.OnReady()
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in New Issue