public void Connect(NetConnection connection, string parameters) { SharedObjectMessage message; if (this._initialSyncReceived) { throw new InvalidOperationException("SharedObject already connected"); } ValidationUtils.ArgumentNotNull(connection, "connection"); ValidationUtils.ArgumentNotNull(connection.Uri, "connection"); ValidationUtils.ArgumentConditionTrue(connection.Uri.Scheme == "rtmp", "connection", "NetConnection object must use the Real-Time Messaging Protocol (RTMP)"); ValidationUtils.ArgumentConditionTrue(connection.Connected, "connection", "NetConnection object must be connected"); this._connection = connection; this._initialSyncReceived = false; if (connection.ObjectEncoding == FluorineFx.ObjectEncoding.AMF0) { message = new SharedObjectMessage(this._name, this._version, this._persistentSO); } else { message = new FlexSharedObjectMessage(this._name, this._version, this._persistentSO); } SharedObjectEvent sharedObjectEvent = new SharedObjectEvent(SharedObjectEventType.SERVER_CONNECT, null, null); message.AddEvent(sharedObjectEvent); this._connection.NetConnectionClient.Write(message); }
public void Close() { if ((this._initialSyncReceived && (this._connection != null)) && this._connection.Connected) { SharedObjectMessage message; if (this._connection.ObjectEncoding == FluorineFx.ObjectEncoding.AMF0) { message = new SharedObjectMessage(this._name, this._version, this._persistentSO); } else { message = new FlexSharedObjectMessage(this._name, this._version, this._persistentSO); } SharedObjectEvent sharedObjectEvent = new SharedObjectEvent(SharedObjectEventType.SERVER_DISCONNECT, null, null); message.AddEvent(sharedObjectEvent); this._connection.NetConnectionClient.Write(message); base.RemoveAttributes(); this._ownerMessage.Events.Clear(); } this._initialSyncReceived = false; }