1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 23:37:41 +00:00

update to /stats

This commit is contained in:
Kane York 2015-11-16 20:35:03 -08:00
parent ab14cdac72
commit c55b5fb277
4 changed files with 18 additions and 16 deletions

View file

@ -107,7 +107,7 @@ func C2SHello(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg
SubscribeDefaults(client) SubscribeDefaults(client)
if client.Version.After(&lastVersionWithoutReplyWithServerTime) { if client.Version.After(&lastVersionWithoutReplyWithServerTime) {
jsTime := float64(time.Now().UnixNano() / 1000) / 1000 jsTime := float64(time.Now().UnixNano()/1000) / 1000
return ClientMessage{ return ClientMessage{
Arguments: []interface{}{ Arguments: []interface{}{
client.ClientID.String(), client.ClientID.String(),
@ -123,7 +123,7 @@ func C2SHello(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg
func C2SPing(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) { func C2SPing(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) {
return ClientMessage{ return ClientMessage{
Arguments: float64(time.Now().UnixNano() / 1000) / 1000, Arguments: float64(time.Now().UnixNano()/1000) / 1000,
}, nil }, nil
} }
@ -150,10 +150,10 @@ func C2SSetUser(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rm
} }
func C2SReady(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) { func C2SReady(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) {
// disconnectAt, err := msg.ArgumentsAsInt() // disconnectAt, err := msg.ArgumentsAsInt()
// if err != nil { // if err != nil {
// return // return
// } // }
client.Mutex.Lock() client.Mutex.Lock()
if client.MakePendingRequests != nil { if client.MakePendingRequests != nil {
@ -171,9 +171,9 @@ func C2SReady(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg
go func() { go func() {
client.MessageChannel <- ClientMessage{MessageID: msg.MessageID, Command: SuccessCommand} client.MessageChannel <- ClientMessage{MessageID: msg.MessageID, Command: SuccessCommand}
SendBacklogForNewClient(client) SendBacklogForNewClient(client)
// if disconnectAt != 0 { // if disconnectAt != 0 {
// SendTimedBacklogMessages(client, time.Unix(disconnectAt, 0)) // SendTimedBacklogMessages(client, time.Unix(disconnectAt, 0))
// } // }
client.MsgChannelKeepalive.Done() client.MsgChannelKeepalive.Done()
}() }()
return ClientMessage{Command: AsyncResponseCommand}, nil return ClientMessage{Command: AsyncResponseCommand}, nil

View file

@ -170,6 +170,7 @@ func RunSocketConnection(conn *websocket.Conn) {
// websocket.Conn is a ReadWriteCloser // websocket.Conn is a ReadWriteCloser
Statistics.ClientConnectsTotal++ Statistics.ClientConnectsTotal++
Statistics.CurrentClientCount++
var _closer sync.Once var _closer sync.Once
closer := func() { closer := func() {
@ -263,7 +264,6 @@ RunLoop:
case msg := <-clientChan: case msg := <-clientChan:
if client.VersionString == "" && msg.Command != HelloCommand { if client.VersionString == "" && msg.Command != HelloCommand {
CloseConnection(conn, &CloseFirstMessageNotHello) CloseConnection(conn, &CloseFirstMessageNotHello)
Statistics.FirstNotHelloDisconnects++
break RunLoop break RunLoop
} }
@ -308,6 +308,7 @@ RunLoop:
close(_serverMessageChan) close(_serverMessageChan)
Statistics.ClientDisconnectsTotal++ Statistics.ClientDisconnectsTotal++
Statistics.CurrentClientCount--
} }
func getDeadline() time.Time { func getDeadline() time.Time {

View file

@ -7,9 +7,10 @@ import (
) )
type StatsData struct { type StatsData struct {
CurrentClientCount int64
ClientConnectsTotal int64 ClientConnectsTotal int64
ClientDisconnectsTotal int64 ClientDisconnectsTotal int64
FirstNotHelloDisconnects int64
DisconnectCodes map[string]int64 DisconnectCodes map[string]int64
DisconnectReasons map[string]int64 DisconnectReasons map[string]int64

View file

@ -2,11 +2,11 @@ package server
import ( import (
"encoding/json" "encoding/json"
"fmt"
"github.com/satori/go.uuid" "github.com/satori/go.uuid"
"net" "net"
"sync" "sync"
"time" "time"
"fmt"
) )
const CryptoBoxKeyLength = 32 const CryptoBoxKeyLength = 32