@@ -24,15 +24,15 @@ import (
2424
2525type ServerManager struct {
2626 serverList * util.List [WebSocketServer ]
27- reconnectTesting bool
28- primaryServer string
29- ip string
30- port int
31- debugEnabled bool
32- strictMode bool
33- sslEnabled bool
34- protocolHttp string
35- protocolWs string
27+ reconnectTesting bool // Indicates if the server is in the process of running a simulation server reconnect/restart
28+ primaryServer string // The current primary server by its ID. This should be in serverList
29+ ip string // IP the server will bind to
30+ port int // Port the server will bind to
31+ debugEnabled bool // Indicates if the server was started with --debug
32+ strictMode bool // Indicates if the server was started with --require-subscriptions
33+ sslEnabled bool // Indicates if the server was started with --ssl
34+ protocolHttp string // String for the HTTP protocol URIs (http or https)
35+ protocolWs string // String for the WS protocol URIs (ws or wss)
3636}
3737
3838var serverManager * ServerManager
@@ -269,11 +269,13 @@ func subscriptionPageHandlerGet(w http.ResponseWriter, r *http.Request) {
269269 Status : subscription .Status ,
270270 Type : subscription .Type ,
271271 Version : subscription .Version ,
272- Condition : EmptyStruct {} ,
272+ Condition : subscription . Conditions ,
273273 CreatedAt : subscription .CreatedAt ,
274274 Transport : SubscriptionTransport {
275- Method : "websocket" ,
276- SessionID : fmt .Sprintf ("%v_%v" , server .ServerId , clientName ),
275+ Method : "websocket" ,
276+ SessionID : fmt .Sprintf ("%v_%v" , server .ServerId , clientName ),
277+ ConnectedAt : subscription .ClientConnectedAt ,
278+ DisconnectedAt : subscription .ClientDisconnectedAt ,
277279 },
278280 Cost : 0 ,
279281 })
@@ -378,6 +380,8 @@ func subscriptionPageHandlerPost(w http.ResponseWriter, r *http.Request) {
378380 CreatedAt : time .Now ().UTC ().Format (time .RFC3339Nano ),
379381 Status : STATUS_ENABLED , // https://dev.twitch.tv/docs/api/reference/#get-eventsub-subscriptions
380382 SessionClientName : clientName ,
383+ Conditions : body .Condition ,
384+ ClientConnectedAt : client .ConnectedAtTimestamp ,
381385 }
382386
383387 var subs []Subscription
@@ -397,19 +401,21 @@ func subscriptionPageHandlerPost(w http.ResponseWriter, r *http.Request) {
397401 w .WriteHeader (http .StatusAccepted )
398402
399403 json .NewEncoder (w ).Encode (& SubscriptionPostSuccessResponse {
400- Body : SubscriptionPostSuccessResponseBody {
401- ID : subscription .SubscriptionID ,
402- Status : subscription .Status ,
403- Type : subscription .Type ,
404- Version : subscription .Version ,
405- Condition : EmptyStruct {},
406- CreatedAt : subscription .CreatedAt ,
407- Transport : SubscriptionTransport {
408- Method : "websocket" ,
409- SessionID : fmt .Sprintf ("%v_%v" , server .ServerId , clientName ),
410- ConnectedAt : client .ConnectedAtTimestamp ,
404+ Data : []SubscriptionPostSuccessResponseBody {
405+ {
406+ ID : subscription .SubscriptionID ,
407+ Status : subscription .Status ,
408+ Type : subscription .Type ,
409+ Version : subscription .Version ,
410+ Condition : subscription .Conditions ,
411+ CreatedAt : subscription .CreatedAt ,
412+ Transport : SubscriptionTransport {
413+ Method : "websocket" ,
414+ SessionID : fmt .Sprintf ("%v_%v" , server .ServerId , clientName ),
415+ ConnectedAt : client .ConnectedAtTimestamp ,
416+ },
417+ Cost : 0 ,
411418 },
412- Cost : 0 ,
413419 },
414420 Total : 0 ,
415421 MaxTotalCost : 10 ,
@@ -519,7 +525,7 @@ func handlerResponseErrorUnauthorized(w http.ResponseWriter, message string) {
519525func handlerResponseErrorConflict (w http.ResponseWriter , message string ) {
520526 w .WriteHeader (http .StatusConflict )
521527 bytes , _ := json .Marshal (& SubscriptionPostErrorResponse {
522- Error : "Unauthorized " ,
528+ Error : "Conflict " ,
523529 Message : message ,
524530 Status : 409 ,
525531 })
0 commit comments