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
typeHandshakeStateuint8const (
HandshakeInitHandshakeState=iotaHandshakeStart// C -> S, without session key(or session expired)HandshakeAgain// S -> C, with new session keyHandshakeRestart// C -> S, with new session keyHandshakeSuccess// S -> C, handshake accepted
)
func (stateHandshakeState) String() string {
switchstate {
caseHandshakeInit:
return"HandshakeInit"caseHandshakeStart:
return"HandshakeStart"caseHandshakeAgain:
return"HandshakeAgain"caseHandshakeRestart:
return"HandshakeRestart"caseHandshakeSuccess:
return"HandshakeSuccess"default:
returnfmt.Sprintf("HandshakeState(%d)", state)
}
}
constHANDSHAKE="handshake"// HandshakeCommand defines the interface for handshake commands (session initialization)//// # Implements the Command interface for DIM network session establishment//// Data Format: {// "type": 0x88,// "sn": 123,//// "command": "handshake",// "title": "Hello world!", // Handshake state indicator ("DIM?", "DIM!")// "session": "{SESSION_KEY}" // Session key for authenticated communication// }typeHandshakeCommandinterface {
Command// Title returns the handshake state indicator (e.g., "DIM?", "DIM!")//// Returns: String representing the current handshake stateTitle() string// SessionKey returns the session key for authenticated communication//// Returns: Session key string (empty string if not established)SessionKey() string// State returns the structured HandshakeState derived from the title//// Returns: Enumerated HandshakeState valueState() HandshakeState
}
import . "github.com/dimchat/dkd-go/protocol"// AppContent defines the interface for application-customized message contents//// Extends the base Content interface for messages intended for a specific application//// Data structure: {// "type" : i2s(0xA0),// "sn" : 123,//// "app" : "{APP_ID}", // application (e.g.: "chat.dim.sechat")// "extra": info // others// }typeAppContentinterface {
Content// Application returns the target application ID (e.g., "chat.dim.sechat")Application() string
}
// CustomizedContent defines the interface for customized message contents//// Extends the base Content interface for messages intended for a specific module + action//// Data structure: {// "type" : i2s(0xCC),// "sn" : 123,//// "mod" : "{MODULE}", // module name (e.g.: "drift_bottle")// "act" : "{ACTION}", // action name (3.g.: "throw")// "extra": info // action parameters// }typeCustomizedContentinterface {
Content// Module returns the target module name within the application (e.g., "drift_bottle")Module() string// Action returns the action name to execute in the module (e.g., "throw")Action() string
}