-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
109 lines (86 loc) · 3.03 KB
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package opentok
import "encoding/xml"
type xmlSessions struct {
XMLName xml.Name `xml:"sessions"`
Sessions []xmlSession `xml:"Session"`
}
type xmlSession struct {
XMLName xml.Name `xml:"Session"`
PartnerID int `xml:"partner_id"`
SessionID string `xml:"session_id"`
CreateDate string `xml:"create_dt"`
}
// MediaMode specifies how the streams will be managed
// by the OpenTok platform
type MediaMode string
const (
// Routed the streams are handled by our routing component, Mantis.
// This mode is useful for sessions with more than 3 participants
// or sessions that need archiving
Routed MediaMode = "disabled"
// Relayed the streams are either send P2P, if possible. If that's not
// possible, they are routed to a TURN server. When using this mode,
// archiving will not be available.
// Useful for sessions with up to three people that do not need
// archiving
Relayed = "enabled"
)
// ArchiveMode is the archiving mode that is used by the session
type ArchiveMode string
const (
// Always archiveMode will archive the session always, and
// ArchiveStart and ArchiveStop cannot be used
Always ArchiveMode = "always"
// Manual is the default archiveMode. The client can use
// ArchiveStart and ArchiveStop to start and stop archiving
Manual ArchiveMode = "manual"
)
// SessionProps contains the different options when creating a
// new session object
type SessionProps struct {
// Location an IP address that enables the user to specifiy a preferred
// location to be considered when creating the session in
// the platform
Location string
MediaMode MediaMode
ArchiveMode ArchiveMode
}
// Role for a client connected to an OpenTok Session
type Role string
const (
// Moderator has the highest level of control in the session.
// Can subscribe and pubslish to a session and can also force
// the disconnections of other participants in the session
Moderator Role = "moderator"
// Publisher is the default role. It allows the participants to
// subscribe to the streams sent by other participants as well as
// pubslish its own stream to the session
Publisher Role = "publisher"
// Subscriber is the role with the lowest control. It's only allowed
// to subscribe to the streams in the session published by publishers
// and moderators and cannot publish its stream
Subscriber Role = "subscriber"
)
// Token used by the opentok clients to connect to a session
type Token string
func (t *Token) String() string {
return string(*t)
}
// TokenProps are the properties that can be set when creating
// a token
type TokenProps struct {
// Role that the client using that token will have in the opentok
// session
Role Role
// ExpireTime is the time that the token can be used to access a
// token before it expires
ExpireTime int64
// Data is any extra data that needs to be added to the token. It
// can be used to store information about the client that will use
// it to connect to the OpenTok Session
Data string
}
// Session struct that represents an OpenTok Session
type Session struct {
ID string
}