Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

rianders
Posts: 3
Joined: 14 Dec 2016, 15:56

Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Postby rianders » 14 Dec 2016, 16:06

Good news. The connector example works.

Bad news. In any project I set up from scratch myself using the latest 1.7.1 Plugins I get an error:
smartFox = new SmartFox(UseWebSocket.WS);
The name 'UseWebSocket' does no exist in the current context.

Is there a chance it's confused about what to .dll to use or a path problem to the websocket info?



Code: Select all

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Entities;
using Sfs2X.Entities.Data;
using Sfs2X.Entities.Variables;
using Sfs2X.Requests;
using Sfs2X.Logging;

public class HelloWebSocket : MonoBehaviour {
   private string defaultHost = "127.0.0.1";   // Default host
   private int defaultTcpPort = 9933;         // Default TCP port
   private int defaultWsPort = 8888;         // Default WebSocket port
   private SmartFox smartFox;
   
   // Use this for initialization
   void Start () {
      // Initialize SFS2X client and add listeners
      // WebGL build uses a different constructor
      #if !UNITY_WEBGL
      smartFox = new SmartFox();
      #else
      smartFox = new SmartFox(UseWebSocket.WS);
      #endif
   }
}
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Postby Bax » 14 Dec 2016, 17:16

Make sure you linked the DLLs as described in the documentation: http://docs2x.smartfoxserver.com/Gettin ... api-csharp
You have to link both the "Unity" DLL and the "WebGL" DLL in your project, assigning the first one to Editor, Standalone, WebPlayer (and more) and the second one to WebGL builds only.
Paolo Bax
The SmartFoxServer Team
rianders
Posts: 3
Joined: 14 Dec 2016, 15:56

Re: Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Postby rianders » 14 Dec 2016, 19:29

I matched the settings. This error only shows when WebGL is the target. Any chance the two different DLLs could be merged?

Image

Image
rianders
Posts: 3
Joined: 14 Dec 2016, 15:56

Re: Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Postby rianders » 14 Dec 2016, 19:46

Turns out the crufty code I was using didn't use this line:

Code: Select all

using Sfs2X.Util;


So the UseWebSocket.WS must be in the Util area.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity5.5 WebGL UseWebSocket.WS does not exist in current context

Postby Bax » 14 Dec 2016, 23:12

I'm not sure why Unity didn't warn you during the compilation.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 26 guests