mirror of
https://github.com/tinode/chat.git
synced 2025-03-14 10:05:07 +00:00
gofmt -w
This commit is contained in:
@ -18,7 +18,9 @@ import (
|
||||
)
|
||||
|
||||
// Singned AppID. Composition:
|
||||
// [1:algorithm version][4:appid][2:key sequence][1:isRoot][16:signature] = 24 bytes
|
||||
//
|
||||
// [1:algorithm version][4:appid][2:key sequence][1:isRoot][16:signature] = 24 bytes
|
||||
//
|
||||
// convertible to base64 without padding. All integers are little-endian.
|
||||
// Definitions for byte lengths of key's parts.
|
||||
const (
|
||||
@ -37,7 +39,9 @@ const (
|
||||
)
|
||||
|
||||
// Client signature validation
|
||||
// key: client's secret key
|
||||
//
|
||||
// key: client's secret key
|
||||
//
|
||||
// Returns application id, key type.
|
||||
func checkAPIKey(apikey string) (isValid, isRoot bool) {
|
||||
if declen := base64.URLEncoding.DecodedLen(len(apikey)); declen != apikeyLength {
|
||||
|
@ -116,11 +116,11 @@ func (sess *Session) readOnce(wrt http.ResponseWriter, req *http.Request) (int,
|
||||
|
||||
// serveLongPoll handles long poll connections when WebSocket is not available
|
||||
// Connection could be without sid or with sid:
|
||||
// - if sid is empty, create session, expect a login in the same request, respond and close
|
||||
// - if sid is not empty and there is an initialized session, payload is optional
|
||||
// - if sid is empty, create session, expect a login in the same request, respond and close
|
||||
// - if sid is not empty and there is an initialized session, payload is optional
|
||||
// - if no payload, perform long poll
|
||||
// - if payload exists, process it and close
|
||||
// - if sid is not empty but there is no session, report an error
|
||||
// - if sid is not empty but there is no session, report an error
|
||||
func serveLongPoll(wrt http.ResponseWriter, req *http.Request) {
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
|
||||
|
@ -80,13 +80,14 @@ func (t *Topic) loadContacts(uid types.Uid) error {
|
||||
|
||||
// This topic got a request from a 'me' topic to start/stop sending presence updates.
|
||||
// The originating topic reports its own status in 'what' as "on", "off", "gone" or "?unkn".
|
||||
// "on" - requester came online
|
||||
// "off" - requester is offline now
|
||||
// "?none" - anchor for "+" command: requester status is unknown, won't generate a response
|
||||
// and isn't forwarded to clients.
|
||||
// "gone" - topic deleted or otherwise gone - equivalent of "off+remove"
|
||||
// "?unkn" - requester wants to initiate online status exchange but it's own status is unknown yet. This
|
||||
// notifications is not forwarded to users.
|
||||
//
|
||||
// "on" - requester came online
|
||||
// "off" - requester is offline now
|
||||
// "?none" - anchor for "+" command: requester status is unknown, won't generate a response
|
||||
// and isn't forwarded to clients.
|
||||
// "gone" - topic deleted or otherwise gone - equivalent of "off+remove"
|
||||
// "?unkn" - requester wants to initiate online status exchange but it's own status is unknown yet. This
|
||||
// notifications is not forwarded to users.
|
||||
//
|
||||
// "+" commands:
|
||||
// "+en": enable subscription, i.e. start accepting incoming notifications from the user2;
|
||||
|
@ -1267,9 +1267,10 @@ func (s *Session) note(msg *ClientComMessage) {
|
||||
|
||||
// expandTopicName expands session specific topic name to global name
|
||||
// Returns
|
||||
// topic: session-specific topic name the message recipient should see
|
||||
// routeTo: routable global topic name
|
||||
// err: *ServerComMessage with an error to return to the sender
|
||||
//
|
||||
// topic: session-specific topic name the message recipient should see
|
||||
// routeTo: routable global topic name
|
||||
// err: *ServerComMessage with an error to return to the sender
|
||||
func (s *Session) expandTopicName(msg *ClientComMessage) (string, *ServerComMessage) {
|
||||
if msg.Original == "" {
|
||||
logs.Warn.Println("s.etn: empty topic name", s.sid)
|
||||
|
@ -203,8 +203,8 @@ func (ss *SessionStore) EvictUser(uid types.Uid, skipSid string) {
|
||||
}
|
||||
|
||||
// NodeRestarted removes stale sessions from a restarted cluster node.
|
||||
// - nodeName is the name of affected node
|
||||
// - fingerprint is the new fingerprint of the node.
|
||||
// - nodeName is the name of affected node
|
||||
// - fingerprint is the new fingerprint of the node.
|
||||
func (ss *SessionStore) NodeRestarted(nodeName string, fingerprint int64) {
|
||||
ss.lock.Lock()
|
||||
defer ss.lock.Unlock()
|
||||
|
@ -19,9 +19,10 @@ import (
|
||||
|
||||
// A simple implementation of histogram expvar.Var.
|
||||
// `Bounds` specifies the histogram buckets as follows (length = len(bounds)):
|
||||
// (-inf, Bounds[i]) for i = 0
|
||||
// [Bounds[i-1], Bounds[i]) for 0 < i < length
|
||||
// [Bounds[i-1], +inf) for i = length
|
||||
//
|
||||
// (-inf, Bounds[i]) for i = 0
|
||||
// [Bounds[i-1], Bounds[i]) for 0 < i < length
|
||||
// [Bounds[i-1], +inf) for i = length
|
||||
type histogram struct {
|
||||
Count int64 `json:"count"`
|
||||
Sum float64 `json:"sum"`
|
||||
|
@ -113,7 +113,7 @@ type storeObj struct{}
|
||||
|
||||
// Open initializes the persistence system. Adapter holds a connection pool for a database instance.
|
||||
//
|
||||
// name - name of the adapter rquested in the config file
|
||||
// name - name of the adapter rquested in the config file
|
||||
// jsonconf - configuration string
|
||||
func (storeObj) Open(workerId int, jsonconf json.RawMessage) error {
|
||||
if err := openAdapter(workerId, jsonconf); err != nil {
|
||||
|
@ -104,9 +104,10 @@ func normalizeTags(src []string) types.StringSlice {
|
||||
}
|
||||
|
||||
// stringDelta extracts the slices of added and removed strings from two slices:
|
||||
// added := newSlice - (oldSlice & newSlice) -- present in new but missing in old
|
||||
// removed := oldSlice - (oldSlice & newSlice) -- present in old but missing in new
|
||||
// intersection := oldSlice & newSlice -- present in both old and new
|
||||
//
|
||||
// added := newSlice - (oldSlice & newSlice) -- present in new but missing in old
|
||||
// removed := oldSlice - (oldSlice & newSlice) -- present in old but missing in new
|
||||
// intersection := oldSlice & newSlice -- present in both old and new
|
||||
func stringSliceDelta(rold, rnew []string) (added, removed, intersection []string) {
|
||||
if len(rold) == 0 && len(rnew) == 0 {
|
||||
return nil, nil, nil
|
||||
|
Reference in New Issue
Block a user