SmartFox.InitCrypto Method |
Namespace: Sfs2X
public void InitCrypto()
IMPORTANT UNITY REMARKS
This method is not available when building for WebGL: use WSS connection instead.
When building for the Web Player, do not use Security.PrefetchSocketPolicy in your code. In fact this method accepts an IP address only, while you should connect to the domain name instead, since the SSL certificate is (typically) bound to that. Let the Web Player auto-fetch the cross-domain policy from the default TCP port 843. In order to do this, add a listener for such port in the SFS2X AdminTool's Server Configurator module.
void SomeMethod() { SmartFox sfs = new SmartFox(); sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnEncryptionInitialized); sfs.Connect("mysecuredomain.com", 9933); } void OnConnection(BaseEvent evt) { if ((bool)evt.Params["success"]) { Console.WriteLine("Connection was established"); // Initialize encrypted connection sfs.InitCrypto(); } else { Console.WriteLine("Connection failed"); } } void OnEncryptionInitialized(BaseEvent evt) { if ((bool)evt.Params["success"]) { // Do login sfs.Send( new LoginRequest("FozzieTheBear", "", "SimpleChat") ); } else { Console.WriteLine("Encryption initialization failed. Caused by: " + (string)evt.Params["errorMsg"]); } }