Changeset View
Changeset View
Standalone View
Standalone View
lib/socket/socket.react.js
Show All 23 Lines | import { | ||||
serverRequestSocketTimeout, | serverRequestSocketTimeout, | ||||
clientRequestVisualTimeout, | clientRequestVisualTimeout, | ||||
clientRequestSocketTimeout, | clientRequestSocketTimeout, | ||||
} from '../shared/timeouts.js'; | } from '../shared/timeouts.js'; | ||||
import { | import { | ||||
logInActionSources, | logInActionSources, | ||||
type LogOutResult, | type LogOutResult, | ||||
} from '../types/account-types.js'; | } from '../types/account-types.js'; | ||||
import { isWebPlatform } from '../types/device-types.js'; | |||||
import type { CalendarQuery } from '../types/entry-types.js'; | import type { CalendarQuery } from '../types/entry-types.js'; | ||||
import { forcePolicyAcknowledgmentActionType } from '../types/policy-types.js'; | import { forcePolicyAcknowledgmentActionType } from '../types/policy-types.js'; | ||||
import type { Dispatch } from '../types/redux-types.js'; | import type { Dispatch } from '../types/redux-types.js'; | ||||
import { | import { | ||||
serverRequestTypes, | serverRequestTypes, | ||||
type ClientClientResponse, | type ClientClientResponse, | ||||
type ClientServerRequest, | type ClientServerRequest, | ||||
} from '../types/request-types.js'; | } from '../types/request-types.js'; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | class Socket extends React.PureComponent<Props, State> { | ||||
state: State = { | state: State = { | ||||
inflightRequests: null, | inflightRequests: null, | ||||
}; | }; | ||||
socket: ?CommTransportLayer; | socket: ?CommTransportLayer; | ||||
nextClientMessageID: number = 0; | nextClientMessageID: number = 0; | ||||
listeners: Set<SocketListener> = new Set(); | listeners: Set<SocketListener> = new Set(); | ||||
pingTimeoutID: ?TimeoutID; | pingTimeoutID: ?TimeoutID; | ||||
messageLastReceived: ?number; | messageLastReceived: ?number; | ||||
initialPlatformDetailsSent: boolean = | initialPlatformDetailsSent: boolean = isWebPlatform( | ||||
getConfig().platformDetails.platform === 'web'; | getConfig().platformDetails.platform, | ||||
); | |||||
reopenConnectionAfterClosing: boolean = false; | reopenConnectionAfterClosing: boolean = false; | ||||
invalidationRecoveryInProgress: boolean = false; | invalidationRecoveryInProgress: boolean = false; | ||||
initializedWithUserState: ?PreRequestUserState; | initializedWithUserState: ?PreRequestUserState; | ||||
failuresAfterPolicyAcknowledgment: number = 0; | failuresAfterPolicyAcknowledgment: number = 0; | ||||
openSocket(newStatus: ConnectionStatus) { | openSocket(newStatus: ConnectionStatus) { | ||||
if ( | if ( | ||||
this.props.frozen || | this.props.frozen || | ||||
(getConfig().platformDetails.platform !== 'web' && | (!isWebPlatform(getConfig().platformDetails.platform) && | ||||
(!this.props.cookie || !this.props.cookie.startsWith('user='))) | (!this.props.cookie || !this.props.cookie.startsWith('user='))) | ||||
) { | ) { | ||||
return; | return; | ||||
} | } | ||||
if (this.socket) { | if (this.socket) { | ||||
const { status } = this.props.connection; | const { status } = this.props.connection; | ||||
if (status === 'forcedDisconnecting') { | if (status === 'forcedDisconnecting') { | ||||
this.reopenConnectionAfterClosing = true; | this.reopenConnectionAfterClosing = true; | ||||
▲ Show 20 Lines • Show All 635 Lines • Show Last 20 Lines |