(state)
| 1011 | * disconnected - permanent state |
| 1012 | */ |
| 1013 | _updateConnectionState(state) { |
| 1014 | const oldstate = this._rfbConnectionState; |
| 1015 | |
| 1016 | if (state === oldstate) { |
| 1017 | Log.Debug("Already in state '" + state + "', ignoring"); |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | // The 'disconnected' state is permanent for each RFB object |
| 1022 | if (oldstate === 'disconnected') { |
| 1023 | Log.Error("Tried changing state of a disconnected RFB object"); |
| 1024 | return; |
| 1025 | } |
| 1026 | |
| 1027 | // Ensure proper transitions before doing anything |
| 1028 | switch (state) { |
| 1029 | case 'connected': |
| 1030 | if (oldstate !== 'connecting') { |
| 1031 | Log.Error("Bad transition to connected state, " + |
| 1032 | "previous connection state: " + oldstate); |
| 1033 | return; |
| 1034 | } |
| 1035 | break; |
| 1036 | |
| 1037 | case 'disconnected': |
| 1038 | if (oldstate !== 'disconnecting') { |
| 1039 | Log.Error("Bad transition to disconnected state, " + |
| 1040 | "previous connection state: " + oldstate); |
| 1041 | return; |
| 1042 | } |
| 1043 | break; |
| 1044 | |
| 1045 | case 'connecting': |
| 1046 | if (oldstate !== '') { |
| 1047 | Log.Error("Bad transition to connecting state, " + |
| 1048 | "previous connection state: " + oldstate); |
| 1049 | return; |
| 1050 | } |
| 1051 | break; |
| 1052 | |
| 1053 | case 'disconnecting': |
| 1054 | if (oldstate !== 'connected' && oldstate !== 'connecting') { |
| 1055 | Log.Error("Bad transition to disconnecting state, " + |
| 1056 | "previous connection state: " + oldstate); |
| 1057 | return; |
| 1058 | } |
| 1059 | break; |
| 1060 | |
| 1061 | default: |
| 1062 | Log.Error("Unknown connection state: " + state); |
| 1063 | return; |
| 1064 | } |
| 1065 | |
| 1066 | // State change actions |
| 1067 | |
| 1068 | this._rfbConnectionState = state; |
| 1069 | |
| 1070 | Log.Debug("New state '" + state + "', was '" + oldstate + "'."); |
no test coverage detected