0

I have a c# console application that I want to use for a game server the client is being written is as3. I am going to embed the swf into a c# form later. I have a couple questions, I'm really hoping someone can help me figure this out. Currently I have it set up to send a request to log in to the server, at which point the server checks information you put in the username and password fields and verifies the information. If you are authenticated you get connected. My issue is I can't figure out how to send specific information back to flash, such as a string or int. I want to do this for things like displaying user stats for example. I looked at many tutorials but most are about using a flash application that is embedded in a c# server application, and does not operate the same way I need it to.

I just want to send a string or int from my c# server to my flash application that I have retrieved from mysql. so if anyone can just show me how to send a string or int to flash as a raw value please let me know :)

If you can please post a snippet of code... I am still very new as3 c# communication.

also if you need the source please contact me on skype Skype = Serifaz2 I don't want to just publicly post it ... sorry :(

Serifaz
  • 9
  • 6
  • also I forgot to mention If anyone knows of a way i can make the server be accessed from other computers with crossdomain please also add me :) – Serifaz Mar 19 '17 at 20:45
  • To send binary data between Flash/AS3 client and some server both in full duplex mode you are to use Socket class on AS3 side. Server should first serve a socket policy to new connected client, explained here: http://stackoverflow.com/questions/7412203/flash-socket-cross-domain-security-issue Client-side code example here: http://stackoverflow.com/questions/5978480/as3-flash-air-socket-communication-writeutfbytes-only-works-once – Organis Mar 19 '17 at 22:33
  • Ok so I see that is how I would get the crossdomain and client side working. but how would I send the int or string to flash, and then retrieve it in flash? Sorry I don't know if this was already answered but I didn't see on those pages how to do that. – Serifaz Mar 20 '17 at 07:50
  • Normally you google something like > "as3 socket example" and get a lot of relevant links including official documentation pages http://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b0-181c51321220efd9d1c-8000.html or http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html – Organis Mar 20 '17 at 09:29
  • I did actually look that up. I came up with nothing. and the adobe pages don't show how to send anything from the c# end of things. Can you please give me an example of how I would send a string or an int from c# and retrieve it in as3? – Serifaz Mar 20 '17 at 19:02
  • StackOverflow is not a free code writing service. Developers help here each other to understand things, not to google basic examples. You are actually **supposed** to search for "as3 socket example" and "c# server socket example" by your own and try to use them and understand how they work. At the very least. – Organis Mar 20 '17 at 20:19

1 Answers1

0

Nevermind I figured it out. It was actually pretty simple. C#

 Socket socket = TcpClient.Client;
                                    string UserTest = "" + Username;
                                    try
                                    { // sends the text with timeout 10s
                                        UserInfo.Send(socket, Encoding.UTF8.GetBytes(UserTest), 0, UserTest.Length, 1000000);
                                    }
                                    catch (Exception ex) { /* ... */ }

AS3

 while(socket.bytesAvailable)
        {
      var str:String = this.socket.readUTFBytes(this.socket.bytesAvailable);
      trace(str);
        myTrace("you have something");
       }
Serifaz
  • 9
  • 6