Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Example code! Help! #21

Open
ghost opened this issue Feb 11, 2014 · 5 comments
Open

Error with Example code! Help! #21

ghost opened this issue Feb 11, 2014 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 11, 2014

Here is my code

using UnityEngine;
using SimpleJson;
using SuperSocket;
using WebSocket4Net;
using SocketIOClient;


public class test : MonoBehaviour{

    // Use this for initialization

    Client client = new Client("http://localhost:3998");

    void Start () {
        client.Opened += SocketOpened;
        client.Connect();
    }

    void SocketOpened(object sender, MessageEventArgs e){
        Debug.Log("connected");
    }

    // Update is called once per frame
    void Update () {

    }
}

This is my Error:

http://i.imgur.com/9NIwqhz.png

@CapsE
Copy link

CapsE commented Apr 25, 2014

Same here :( sadly I got no solution for you so far.

@CapsE
Copy link

CapsE commented Apr 30, 2014

I found a solution now. Only the SocketMessage event uses the MessageEventArgs class. All other events expect the normal EventArgs class. Change your code to that and make sure to import the System namespace (using System). That should fix this error.

@saied63
Copy link

saied63 commented Sep 17, 2014

i have same problem please help me

This id my code:
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
//using System.Threading.Tasks;
using System.Linq;
using System.Net;
using System.Threading;
using SocketIOClient.Eventing;
using SocketIOClient.Messages;
using WebSocket4Net;

using SocketIOClient;

public class soketIO : MonoBehaviour {

SocketIOClient.Client client = new SocketIOClient.Client("http://localhost:80/");
// Use this for initialization
void Start () {
    client.Opened += SocketOpened;
    client.Message += SocketMessage;
    client.SocketConnectionClosed += SocketConnectionClosed;
    client.Error +=SocketError;

    client.Connect();

}


private void SocketOpened(object sender, SocketIOClient.MessageEventArgs e) {
    //invoke when socket opened
    print ("soket is opened");
}

void Update(){
    if(Input.GetKeyDown("c")){

        //client.Send(SocketIOClient.Messages.IMessage);
    }
}


private void SocketMessage (object sender, SocketIOClient.MessageEventArgs e) {
    if ( e!= null && e.Message.Event == "message") {
        string msg = e.Message.MessageText;
        process(msg);
    }
}

I got these errors :

Assets/soketIO.cs(25,24): error CS0123: A method or delegate soketIO.SocketOpened(object, SocketIOClient.MessageEventArgs)' parameters do not match delegateSystem.EventHandler(object, System.EventArgs)' parameters
#########################################
Assets/soketIO.cs(25,24): error CS0428: Cannot convert method group SocketOpened' to non-delegate typeSystem.EventHandler'. Consider using parentheses to invoke the method
#########################################
Assets/soketIO.cs(27,50): error CS0103: The name SocketConnectionClosed' does not exist in the current context ######################################## Assets/soketIO.cs(28,32): error CS0103: The nameSocketError' does not exist in the current context
########################################
Assets/soketIO.cs(51,25): error CS0103: The name `process' does not exist in the current context

@CSEliot
Copy link

CSEliot commented Mar 9, 2015

CapsE's Solution works for me.

@withtea
Copy link

withtea commented Jun 9, 2015

private void SocketOpened(object sender, System.EventArgs e)
{
    //invoke when socket opened
}

that all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants