(conn *websocket.Conn)
| 966 | } |
| 967 | |
| 968 | func HandleWebSocketConnection(conn *websocket.Conn) { |
| 969 | |
| 970 | var userObject *users.UserRecord |
| 971 | connDetails := connections.Add(nil, conn) |
| 972 | |
| 973 | // Setup shared state map for this connection's handlers |
| 974 | // Needs to be created BEFORE the first handler call |
| 975 | var sharedState map[string]any = make(map[string]any) |
| 976 | |
| 977 | // Describes whatever the client sent us |
| 978 | clientInput := &connections.ClientInput{ |
| 979 | ConnectionId: connDetails.ConnectionId(), |
| 980 | DataIn: []byte{}, |
| 981 | Buffer: make([]byte, 0, connections.ReadBufferSize), |
| 982 | EnterPressed: false, |
| 983 | Clipboard: []byte{}, |
| 984 | History: connections.InputHistory{}, |
| 985 | } |
| 986 | |
| 987 | connections.SendTo( |
| 988 | []byte("!!SOUND(Off U="+configs.GetConfig().FilePaths.WebCDNLocation.String()+")"), |
| 989 | clientInput.ConnectionId, |
| 990 | ) |
| 991 | |
| 992 | plugins.OnNetConnect(connDetails) |
| 993 | |
| 994 | loginHandler := inputhandlers.GetLoginPromptHandler() |
| 995 | connDetails.AddInputHandler("LoginPromptHandler", loginHandler) |
| 996 | |
| 997 | if audioConfig := audio.GetFile(`intro`); audioConfig.FilePath != `` { |
| 998 | v := 100 |
| 999 | if audioConfig.Volume > 0 && audioConfig.Volume <= 100 { |
| 1000 | v = audioConfig.Volume |
| 1001 | } |
| 1002 | connections.SendTo( |
| 1003 | []byte("!!MUSIC("+audioConfig.FilePath+" V="+strconv.Itoa(v)+" L=-1 C=1)"), |
| 1004 | clientInput.ConnectionId, |
| 1005 | ) |
| 1006 | } |
| 1007 | |
| 1008 | splashTxt, _ := templates.Process("login/connect-splash", nil) |
| 1009 | connections.SendTo([]byte(templates.AnsiParse(splashTxt)), connDetails.ConnectionId()) |
| 1010 | |
| 1011 | initialTriggerInput := &connections.ClientInput{ |
| 1012 | ConnectionId: connDetails.ConnectionId(), |
| 1013 | } |
| 1014 | loginHandler(initialTriggerInput, sharedState) |
| 1015 | |
| 1016 | c := configs.GetConfig() |
| 1017 | |
| 1018 | for { |
| 1019 | _, message, err := conn.ReadMessage() |
| 1020 | |
| 1021 | if err != nil { |
| 1022 | |
| 1023 | // If failed to read from the connection, switch to linkdead state |
| 1024 | if userObject != nil { |
| 1025 |
nothing calls this directly
no test coverage detected