本文整理汇总了Golang中github.com/strukturag/spreed-webrtc/go/channelling.Session.Userid方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.Userid方法的具体用法?Golang Session.Userid怎么用?Golang Session.Userid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/strukturag/spreed-webrtc/go/channelling.Session
的用法示例。
在下文中一共展示了Session.Userid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HandleAuthentication
func (api *channellingAPI) HandleAuthentication(session *channelling.Session, st *channelling.SessionToken) (*channelling.DataSelf, error) {
if err := api.SessionManager.Authenticate(session, st, ""); err != nil {
log.Println("Authentication failed", err, st.Userid, st.Nonce)
return nil, err
}
log.Println("Authentication success", session.Userid())
self, err := api.HandleSelf(session)
if err == nil {
session.BroadcastStatus()
}
return self, err
}
示例2: HandleChat
func (api *channellingAPI) HandleChat(session *channelling.Session, chat *channelling.DataChat) {
// TODO(longsleep): Limit sent chat messages per incoming connection.
msg := chat.Chat
to := chat.To
if !msg.NoEcho {
session.Unicast(session.Id, chat, nil)
}
msg.Time = time.Now().Format(time.RFC3339)
if to == "" {
// TODO(longsleep): Check if chat broadcast is allowed.
if session.Hello {
api.StatsCounter.CountBroadcastChat()
session.Broadcast(chat)
}
} else {
if msg.Status != nil {
if msg.Status.ContactRequest != nil {
if !api.config.WithModule("contacts") {
return
}
if err := api.ContactManager.ContactrequestHandler(session, to, msg.Status.ContactRequest); err != nil {
log.Println("Ignoring invalid contact request.", err)
return
}
msg.Status.ContactRequest.Userid = session.Userid()
}
} else {
api.StatsCounter.CountUnicastChat()
}
session.Unicast(to, chat, nil)
if msg.Mid != "" {
// Send out delivery confirmation status chat message.
session.Unicast(session.Id, &channelling.DataChat{To: to, Type: "Chat", Chat: &channelling.DataChatMessage{Mid: msg.Mid, Status: &channelling.DataChatStatus{State: "sent"}}}, nil)
}
}
}
示例3: HandleSelf
func (api *channellingAPI) HandleSelf(session *channelling.Session) (*channelling.DataSelf, error) {
token, err := api.SessionEncoder.EncodeSessionToken(session)
if err != nil {
log.Println("Error in OnRegister", err)
return nil, err
}
log.Println("Created new session token", len(token), token)
self := &channelling.DataSelf{
Type: "Self",
Id: session.Id,
Sid: session.Sid,
Userid: session.Userid(),
Suserid: api.SessionEncoder.EncodeSessionUserID(session),
Token: token,
Version: api.config.Version,
ApiVersion: apiVersion,
Turn: api.TurnDataCreator.CreateTurnData(session),
Stun: api.config.StunURIs,
}
api.BusManager.Trigger(channelling.BusManagerSession, session.Id, session.Userid(), nil, nil)
return self, nil
}