x


can javascript use socket to connect to any socket server

I saw some socket example are all written in c#and I found nothing when i am searching the socket api on script documentationdoes unity has socket api or i have to use the c# api to do a socket connection in other wordsdoes that means js can't do everything that c# can do

more ▼

asked Apr 07 '11 at 10:03 AM

wuesugi gravatar image

wuesugi
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Hello wuesugi,

You can access and you can send message to Smartfox Server in javascript. But NetworkController must be in parent folder and You must import smartfox libs.

import SmartFox;
import SmartFoxClientAPI;
import SmartFoxClientAPI.Data; 

Exaple :

import SmartFox;
import SmartFoxClientAPI;
import SmartFoxClientAPI.Data; 

function Start() 

{

            var client : SmartFoxClient ;
            var  data  : SFSObject ;
            data = new SFSObject();
            client = NetworkController.GetClient();

            data.Put("_cmd","c");       // Create message       
            data.Put("name", gameObject.name);          
            client.SendObject(data);
        }

    }

}

Regards

more ▼

answered Apr 07 '11 at 03:26 PM

Grcan SERBEST gravatar image

Grcan SERBEST
71 1 1 7

Thanks for your answer and example ,it is a great help.But i still wonder can js use socket and the difference of functionality between scripting with js and c#

Apr 08 '11 at 02:39 AM wuesugi
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x60

asked: Apr 07 '11 at 10:03 AM

Seen: 1356 times

Last Updated: Apr 07 '11 at 10:03 AM