Fixing up some comments

This commit is contained in:
Sarah Jamie Lewis 2016-11-08 15:04:11 -08:00
parent c37f9008b6
commit 9d6592e1e4
4 changed files with 12 additions and 2 deletions

View File

@ -43,6 +43,8 @@ func (r *Ricochet) Connect(host string) (*OpenConnection, error) {
return r.ConnectOpen(conn, host)
}
// ConnectOpen attempts to open up a new connection to the given host. Returns a
// pointer to the OpenConnection or an error.
func (r *Ricochet) ConnectOpen(conn net.Conn, host string) (*OpenConnection, error) {
oc, err := r.negotiateVersion(conn, true)
if err != nil {
@ -64,6 +66,8 @@ func (r *Ricochet) Server(service RicochetService, port int) {
r.ServeListener(service, ln)
}
// ServeListener processes all messages given by the listener ln with the given
// RicochetService, service.
func (r *Ricochet) ServeListener(service RicochetService, ln net.Listener) {
go r.ProcessMessages(service)
service.OnReady()
@ -100,7 +104,7 @@ func (r *Ricochet) ProcessMessages(service RicochetService) {
}
}
// Request that the ProcessMessages loop is stopped after handling all currently
// RequestStopMessageLoop requests that the ProcessMessages loop is stopped after handling all currently
// queued new connections.
func (r *Ricochet) RequestStopMessageLoop() {
r.newconns <- nil

View File

@ -138,7 +138,7 @@ func (srs *StandardRicochetService) OnOpenChannelRequest(oc *OpenConnection, cha
func (srs *StandardRicochetService) OnOpenChannelRequestSuccess(oc *OpenConnection, channelID int32) {
}
// OnChannelClose is called when a client or server closes an existing channel
// OnChannelClosed is called when a client or server closes an existing channel
func (srs *StandardRicochetService) OnChannelClosed(oc *OpenConnection, channelID int32) {
}

View File

@ -3,6 +3,7 @@ package utils
import "fmt"
import "log"
// RecoverFromError doesn't really recover from anything....see comment below
func RecoverFromError() {
if r := recover(); r != nil {
// This should only really happen if there is a failure de/serializing. If
@ -12,6 +13,9 @@ func RecoverFromError() {
}
}
// CheckError is a helper function for panicing on errors which we need to handle
// but should be very rare e.g. failures deserializing a protobuf object that
// should only happen if there was a bug in the underlying library.
func CheckError(err error) {
if err != nil {
panic(fmt.Sprintf("%v", err))

View File

@ -14,6 +14,8 @@ type RicochetData struct {
Data []byte
}
//Equals compares a RicochetData object to another and returns true if contain
// the same data.
func (rd RicochetData) Equals(other RicochetData) bool {
return rd.Channel == other.Channel && bytes.Equal(rd.Data, other.Data)
}