SessionModel class

Model to track the state of a call session.

This class represents the current state of a SIP call session, including whether it's on hold, active, part of a conference, etc. Based on the Swift P2PSample Session class from the PortSIP SDK.

This class is immutable. Use copyWith to create modified copies or SessionModel.initial to get a fresh initial state.

Session ID Type Consistency

The sessionId field uses Dart's int type. Due to platform differences in the native PortSIP SDKs:

  • Android: Uses Long (64-bit signed integer)
  • iOS: Uses Int (64-bit on modern devices, but SDK returns 32-bit values)
  • Dart: Uses int (64-bit on all platforms)

For maximum cross-platform compatibility, session IDs are validated to fit within a 32-bit signed integer range (-2,147,483,648 to 2,147,483,647). The PortSIP SDK typically generates session IDs within this range, so this constraint should not affect normal usage.

Example usage:

final session = SessionModel(
  sessionId: callSessionId,
  sessionState: true,
  videoState: false,
);

Constructors

SessionModel({int sessionId = invalidSessionId, bool holdState = false, bool sessionState = false, bool conferenceState = false, bool recvCallState = false, bool isReferCall = false, int originCallSessionId = invalidSessionId, bool existEarlyMedia = false, bool videoState = false})
Creates a new SessionModel with the specified state.
SessionModel.initial()
Creates an initial session state with default values.
factory

Properties

conferenceState bool
Whether this session is part of a conference
final
existEarlyMedia bool
Whether early media exists (audio before call is answered)
final
hashCode int
The hash code for this object.
no setteroverride
holdState bool
Whether the call is on hold
final
isReferCall bool
Whether this is a referred call (transferred)
final
isValid bool
Returns true if the session ID is valid (not -1).
no setter
originCallSessionId int
Original call session ID (for refer/transfer scenarios)
final
recvCallState bool
Whether this is an incoming call waiting to be answered
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionId int
Unique session identifier returned by the SDK.
final
sessionState bool
Whether the session is active (call established)
final
videoState bool
Whether this is a video call
final

Methods

copyWith({int? sessionId, bool? holdState, bool? sessionState, bool? conferenceState, bool? recvCallState, bool? isReferCall, int? originCallSessionId, bool? existEarlyMedia, bool? videoState}) SessionModel
Creates a copy of this session with the specified fields updated.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Constants

invalidSessionId → const int
Invalid session ID constant.
maxSessionId → const int
Maximum valid session ID (32-bit signed integer maximum).
minSessionId → const int
Minimum valid session ID (32-bit signed integer minimum).