Unity 2017 - Error.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Unity 2017 - Error.

Postby Ninjaoninja2 » 08 Oct 2017, 16:36

Hey,
I'm not entirely sure what this error (see error below) is referring to in my C# script.

Error:

Code: Select all

Assets/Scripts/Connect.cs(15,7): error CS0123: A method or delegate `Connect.onLogin()' parameters do not match delegate `Sfs2X.Core.EventListenerDelegate(Sfs2X.Core.BaseEvent)' parameters

Full Code for connect.cs:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using UnityEngine.UI;
public class Connect : MonoBehaviour {
   SmartFox sfs = new SmartFox ();
   // Use this for initialization
   void Start () {
      sfs.Connect ("127.0.0.1", 9933);
      sfs.AddEventListener (SFSEvent.CONNECTION, onConnect);
      sfs.AddEventListener (SFSEvent.CONNECTION_LOST, onConnectFail);
      sfs.AddEventListener (SFSEvent.LOGIN, onLogin);
   }
   
   // Update is called once per frame
   void Update () {
      
   }
   void onConnect (BaseEvent evt) {
      Debug.Log ("It works");
   }
   void onConnectFail(BaseEvent evt) {
      Debug.LogError ("It didn't work.");
   }
   void loginPress() {
      bool loginpress = Input.GetButtonDown ("loginbtn");
      if (loginpress) {
         sfs.Send (new Sfs2X.Requests.LoginRequest ("Username.text", "Password.text", "SimpleMMOWorld"));
      }
   }
   void onLogin() {
      Debug.Log ("Login Succesful");
   }
}


If you guys could point me to where I've gone wrong, it would be super helpful.
Thanks, Zach.
LameOne
Posts: 7
Joined: 25 Sep 2017, 22:36

Re: Unity 2017 - Error.

Postby LameOne » 08 Oct 2017, 21:18

Ninjaoninja2 wrote:Hey,
I'm not entirely sure what this error (see error below) is referring to in my C# script.

Error:

Code: Select all

Assets/Scripts/Connect.cs(15,7): error CS0123: A method or delegate `Connect.onLogin()' parameters do not match delegate `Sfs2X.Core.EventListenerDelegate(Sfs2X.Core.BaseEvent)' parameters

Full Code for connect.cs:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using UnityEngine.UI;
public class Connect : MonoBehaviour {
   SmartFox sfs = new SmartFox ();
   // Use this for initialization
   void Start () {
      sfs.Connect ("127.0.0.1", 9933);
      sfs.AddEventListener (SFSEvent.CONNECTION, onConnect);
      sfs.AddEventListener (SFSEvent.CONNECTION_LOST, onConnectFail);
      sfs.AddEventListener (SFSEvent.LOGIN, onLogin);
   }
   
   // Update is called once per frame
   void Update () {
      
   }
   void onConnect (BaseEvent evt) {
      Debug.Log ("It works");
   }
   void onConnectFail(BaseEvent evt) {
      Debug.LogError ("It didn't work.");
   }
   void loginPress() {
      bool loginpress = Input.GetButtonDown ("loginbtn");
      if (loginpress) {
         sfs.Send (new Sfs2X.Requests.LoginRequest ("Username.text", "Password.text", "SimpleMMOWorld"));
      }
   }
   void onLogin() {
      Debug.Log ("Login Succesful");
   }
}


If you guys could point me to where I've gone wrong, it would be super helpful.
Thanks, Zach.

you need to change

Code: Select all

   void onLogin() {
      Debug.Log ("Login Succesful");
   }


to

Code: Select all

   void onLogin(BaseEvent evt) {
      Debug.Log ("Login Succesful");
   }
Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Re: Unity 2017 - Error.

Postby Ninjaoninja2 » 13 Oct 2017, 17:07

LameOne wrote:
Ninjaoninja2 wrote:Hey,
I'm not entirely sure what this error (see error below) is referring to in my C# script.

Error:

Code: Select all

Assets/Scripts/Connect.cs(15,7): error CS0123: A method or delegate `Connect.onLogin()' parameters do not match delegate `Sfs2X.Core.EventListenerDelegate(Sfs2X.Core.BaseEvent)' parameters

Full Code for connect.cs:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using UnityEngine.UI;
public class Connect : MonoBehaviour {
   SmartFox sfs = new SmartFox ();
   // Use this for initialization
   void Start () {
      sfs.Connect ("127.0.0.1", 9933);
      sfs.AddEventListener (SFSEvent.CONNECTION, onConnect);
      sfs.AddEventListener (SFSEvent.CONNECTION_LOST, onConnectFail);
      sfs.AddEventListener (SFSEvent.LOGIN, onLogin);
   }
   
   // Update is called once per frame
   void Update () {
      
   }
   void onConnect (BaseEvent evt) {
      Debug.Log ("It works");
   }
   void onConnectFail(BaseEvent evt) {
      Debug.LogError ("It didn't work.");
   }
   void loginPress() {
      bool loginpress = Input.GetButtonDown ("loginbtn");
      if (loginpress) {
         sfs.Send (new Sfs2X.Requests.LoginRequest ("Username.text", "Password.text", "SimpleMMOWorld"));
      }
   }
   void onLogin() {
      Debug.Log ("Login Succesful");
   }
}


If you guys could point me to where I've gone wrong, it would be super helpful.
Thanks, Zach.

you need to change

Code: Select all

   void onLogin() {
      Debug.Log ("Login Succesful");
   }


to

Code: Select all

   void onLogin(BaseEvent evt) {
      Debug.Log ("Login Succesful");
   }

I feel so stupid, thanks. xD

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 60 guests