You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/events.go
+8-5
Original file line number
Diff line number
Diff line change
@@ -45,8 +45,6 @@ var (
45
45
clientIdstring
46
46
versionstring
47
47
websocketClientstring
48
-
websocketServerIPstring
49
-
websocketServerPortint
50
48
)
51
49
52
50
// websocketCmd-specific flags
@@ -57,6 +55,9 @@ var (
57
55
wsSubscriptionstring
58
56
wsStatusstring
59
57
wsReasonstring
58
+
wsServerIPstring
59
+
wsServerPortint
60
+
wsSSLbool
60
61
)
61
62
62
63
vareventCmd=&cobra.Command{
@@ -175,8 +176,9 @@ func init() {
175
176
176
177
// websocket flags
177
178
/// flags for start-server
178
-
websocketCmd.Flags().StringVar(&websocketServerIP, "ip", "127.0.0.1", "Defines the ip that the mock EventSub websocket server will bind to.")
179
-
websocketCmd.Flags().IntVarP(&websocketServerPort, "port", "p", 8080, "Defines the port that the mock EventSub websocket server will run on.")
179
+
websocketCmd.Flags().StringVar(&wsServerIP, "ip", "127.0.0.1", "Defines the ip that the mock EventSub websocket server will bind to.")
180
+
websocketCmd.Flags().IntVarP(&wsServerPort, "port", "p", 8080, "Defines the port that the mock EventSub websocket server will run on.")
181
+
websocketCmd.Flags().BoolVar(&wsSSL, "ssl", false, "Enables SSL for EventSub websocket server (wss) and EventSub mock subscription server (https).")
180
182
websocketCmd.Flags().BoolVar(&wsDebug, "debug", false, "Set on/off for debug messages for the EventSub WebSocket server.")
181
183
websocketCmd.Flags().BoolVarP(&wsStrict, "require-subscription", "S", false, "Requires subscriptions for all events, and activates 10 second subscription requirement.")
lightRed("ERROR: Missing one of the required SSL crt/key files."),
119
+
brightWhite(home),
120
+
brightWhite("localhost.crt"),
121
+
brightWhite("localhost.key"),
122
+
lightYellow("** Testing with Twitch CLI using SSL is meant for users experienced with SSL already, as these files must be added to your systems keychain to work without errors. **"),
123
+
keyFile, keyFile, crtFile)
124
+
return
125
+
}
103
126
104
-
log.Printf(lightYellow("Events can be forwarded to this server from another terminal with --transport=websocket\nExample: \"twitch event trigger channel.ban --transport=websocket\""))
105
-
fmt.Println()
106
-
log.Printf(lightYellow("You can send to a specific client after its connected with --session\nExample: \"twitch event trigger channel.ban --transport=websocket --session=e411cc1e_a2613d4e\""))
127
+
printWelcomeMsg()
107
128
108
-
fmt.Println()
109
-
log.Printf(lightGreen("For further usage information, please see our official documentation:\nhttps://dev.twitch.tv/docs/cli/websocket-event-command/"))
110
-
fmt.Println()
129
+
iferr:=http.ServeTLS(listen, m, crtFile, keyFile); err!=nil {
130
+
log.Fatalf("Cannot start HTTP server: %v", err)
131
+
return
132
+
}
133
+
} else {
134
+
serverManager.protocolHttp="http"
135
+
serverManager.protocolWs="ws"
111
136
112
-
log.Printf(lightBlue("Connect to the WebSocket server at: ")+"ws://%v:%v/ws", ip, port)
137
+
printWelcomeMsg()
113
138
114
-
// Serve HTTP server
115
-
iferr:=http.Serve(listen, m); err!=nil {
116
-
log.Fatalf("Cannot start HTTP server: %v", err)
117
-
return
139
+
iferr:=http.Serve(listen, m); err!=nil {
140
+
log.Fatalf("Cannot start HTTP server: %v", err)
141
+
return
142
+
}
118
143
}
144
+
119
145
}()
120
146
121
147
// Initalize RPC handler, to accept EventSub transports
@@ -135,10 +161,41 @@ func StartWebsocketServer(enableDebug bool, ip string, port int, strictMode bool
log.Printf(lightBlue("Started WebSocket server on %v:%v"), serverManager.ip, serverManager.port)
171
+
ifserverManager.strictMode {
172
+
log.Printf(lightBlue("--require-subscription enabled. Clients will have 10 seconds to subscribe before being disconnected."))
173
+
}
174
+
175
+
fmt.Println()
176
+
177
+
log.Printf(yellow("Simulate subscribing to events at: %v://%v:%v/eventsub/subscriptions"), serverManager.protocolHttp, serverManager.ip, serverManager.port)
178
+
log.Printf(yellow("POST, GET, and DELETE are supported"))
179
+
log.Printf(yellow("For more info: https://dev.twitch.tv/docs/cli/websocket-event-command/#simulate-subscribing-to-mock-eventsub"))
180
+
181
+
fmt.Println()
182
+
183
+
log.Printf(lightYellow("Events can be forwarded to this server from another terminal with --transport=websocket\nExample: \"twitch event trigger channel.ban --transport=websocket\""))
184
+
fmt.Println()
185
+
log.Printf(lightYellow("You can send to a specific client after its connected with --session\nExample: \"twitch event trigger channel.ban --transport=websocket --session=e411cc1e_a2613d4e\""))
186
+
187
+
fmt.Println()
188
+
log.Printf(lightGreen("For further usage information, please see our official documentation:\nhttps://dev.twitch.tv/docs/cli/websocket-event-command/"))
189
+
fmt.Println()
190
+
191
+
log.Printf(lightBlue("Connect to the WebSocket server at: ")+"%v://%v:%v/ws", serverManager.protocolWs, serverManager.ip, serverManager.port)
log.Printf("Failed to find primary server [%v] when new client was accessing ws://%v:%v/ws -- Aborting...", serverManager.primaryServer, serverManager.ip, serverManager.port)
197
+
log.Printf("Failed to find primary server [%v] when new client was accessing %v://%v:%v/ws -- Aborting...",
DetailedInfo: "Command \"subscription\" requires flags --status, --subscription, and --session"+
218
-
fmt.Sprintf("\nThe flag --subscription must be the ID of the subscription made at http://%v:%v/eventsub/subscriptions", serverManager.ip, serverManager.port) +
218
+
fmt.Sprintf("\nThe flag --subscription must be the ID of the subscription made at %v://%v:%v/eventsub/subscriptions", serverManager.protocolHttp, serverManager.ip, serverManager.port) +
219
219
"\nThe flag --status must be one of the non-webhook status options defined here:"+
0 commit comments