mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-06-17 14:38:10 -04:00

- Define and use a few constants for the sake of code maintainability - Change log package name to logger so it better reflects its purpose - Fix depredations - Drop unused private methods and constants - Create an auxiliary func newFromPrimary() to reduce code duplicacy. Also straight away type conversion doesn't seem to type-check. Got to explicitly create a new struct instance.
29 lines
618 B
Go
29 lines
618 B
Go
// package sam3 wraps the original sam3 API from github.com/go-i2p/sam3
|
|
package sam3
|
|
|
|
import (
|
|
"github.com/go-i2p/go-sam-go/primary"
|
|
)
|
|
|
|
const (
|
|
session_ADDOK = "SESSION STATUS RESULT=OK"
|
|
)
|
|
|
|
// Represents a primary session.
|
|
type PrimarySession struct {
|
|
*primary.PrimarySession
|
|
}
|
|
|
|
var PrimarySessionSwitch = "MASTER"
|
|
|
|
func (p *PrimarySession) NewStreamSubSession(id string) (*StreamSession, error) {
|
|
log.WithField("id", id).Debug("NewStreamSubSession called")
|
|
session, err := p.PrimarySession.NewStreamSubSession(id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &StreamSession{
|
|
StreamSession: session,
|
|
}, nil
|
|
}
|