GithubHelp home page GithubHelp logo

Error with Example code! Help! about unitysocketio HOT 5 OPEN

 avatar commented on July 30, 2024
Error with Example code! Help!

from unitysocketio.

Comments (5)

withtea avatar withtea commented on July 30, 2024 1
private void SocketOpened(object sender, System.EventArgs e)
{
    //invoke when socket opened
}

that all

from unitysocketio.

CapsE avatar CapsE commented on July 30, 2024

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

from unitysocketio.

CapsE avatar CapsE commented on July 30, 2024

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.

from unitysocketio.

saied63 avatar saied63 commented on July 30, 2024

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

from unitysocketio.

CSEliot avatar CSEliot commented on July 30, 2024

CapsE's Solution works for me.

from unitysocketio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.