User Tag List

Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 32

Thread: MooClick protokol specifications

  1. #11
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Jun 2006
    Posts
    887
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Grim: It sounds like you have wrote ONLY what I have written here

    You have to have also other namespaces like Text (Using System.Text) and so on, I only write the ones that you dont have when start new project.

    Create new project and select Console Application - you will have all prepared and then just add my code.

    However its possible I wrote something uppercase or vice-versa, I wrote it directly here without C#.

  2. #12
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    yes I know that I must select 'console application' ^^

    well I put:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Net;
    using System.Net.Sockets;

    namespace Client
    {
    class Program
    {

    public static void Main(string[] args)
    {
    TpcClient client = new TpcClient();
    Console.WriteLine("Connecting...");
    client.Connect("127.0.0.1", 1204);
    Stream str = klient.GetStream();
    byte[] bb = new byte[100];

    while (client.Connected == true)
    {
    int k = str.Read(bb, 0, 100);
    for (int i = 0; i < k; i++) //put breakpoint here ie
    Console.WriteLine(Convert.ToChar(bb[i]));
    }
    }
    }
    }
    and now errors:

    Error 1 The type or namespace name 'TpcClient' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs 16 13 ConsoleApplication1
    Error 2 The type or namespace name 'TpcClient' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs 16 36 ConsoleApplication1
    Error 3 The name 'klient' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs 19 26 ConsoleApplication1

  3. #13
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Jun 2006
    Posts
    887
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Well, I saw few my typos:

    Error1-2:LOL, I wrote Tpc instead of TCP Sorry, its TcpClient

    Error3: my typo - klient should be "client" everywhere

    Better then copy would be rewrite it and let program fill in the right names of objects

  4. #14
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Thank you, it works now fine

    Note: you must run MooClick server before running your app in c#. Or just simply make app in MMF
    start of frame - mooclick - host server on port xxx and in c# write same port and then run mmf server and next run c# app and it works

    code for app

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Net;
    using System.Net.Sockets;
    
    namespace Client
    {
        class Program
        {
    
            public static void Main(string[] args)
            {
                TcpClient client = new TcpClient();
                Console.WriteLine("Connecting...");
                client.Connect("127.0.0.1", 1203);
    
                Stream str = client.GetStream();
                byte[] bb = new byte[100];
    
                while (client.Connected == true)
                {
                    int k = str.Read(bb, 0, 100);
                    for (int i = 0; i < k; i++) //put breakpoint here ie
                        Console.WriteLine(Convert.ToChar(bb[i]));
                }
            }
        }
    }

  5. #15
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Jun 2006
    Posts
    887
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Thanks for corrections in code.

    Yes of course, this app is meant to be "reader" of messages from MooClick server in order to explore its byte headers.

    You can make also event in MMF2 server - Press "Space"> Select connection with index 0, Send text to connection.

    C# app will recieve the message and if you have breakpoint there, you can look into byte array.

  6. #16
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,515
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)

    Re: MooClick protokol specifications

    SteveTaylor's http://sourceforge.net/projects/mooapi SVN could be useful (it is Java).

    Code:
                case 0: // '\0'
                    return IGNORE;
    
                case 1: // '\001'
                    return MESSAGE_TO_CHANNEL;
    
                case 2: // '\002'
                    return MESSAGE_TO_SERVER;
    
                case 3: // '\003'
                    return MESSAGE_TO_USER;
    
                case 4: // '\004'
                    return USER_JOIN_CHANNEL_REQUEST;
    
                case 5: // '\005'
                    return USER_LEFT_CHANNEL;
    
                case 11: // '\013'
                    return PLAYER_NAME_CHANGE;
    
                case 12: // '\f'
                    return PLAYER_NAME_SENT;
    
                case 6: // '\006'
                case 7: // '\007'
                case 8: // '\b'
                case 9: // '\t'
                case 10: // '\n'
    Code:
    	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    	//                                                                                                               //
    	//                                        OUTPUT PROTOCOL METHODS                                                //
    	//                                                                                                               //
    	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    	// Output command: Message to channel (relayed from incoming client message)
    	// Send a message to this connection from a source connection, on the specified channel and subchannel.
    	public void sendMessage(MooConnection source, String text, MooChannel channel, short subchannel) {
    		//System.out.println("[TX][" + name + "] send message from " + source.getName()
    + " on channel " + channel.getName() + ", subchannel " + subchannel + ": " + text);
    		// Verify that this user is in this channel
    		if (channels.contains(channel)) {
    			byte[] textBytes = text.getBytes();
    			ByteBuffer buffer = ByteBuffer.wrap(new byte[15 + textBytes.length]);
    			buffer.order(ByteOrder.LITTLE_ENDIAN);
    			buffer.put((byte)1);
    			buffer.putShort(subchannel);
    			buffer.putInt(channel.getId());
    			buffer.putInt(source.getId());
    			buffer.putInt(textBytes.length);
    			buffer.put(textBytes);
    			server.send(hostKey, buffer.array());
    		}
    	}
    
    	// Send message of the day
    	public void sendMotd(String motd) {
    		//System.out.println("[TX][" + id + "] send motd: " + motd);
    		byte[] motdBytes = motd.getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[5 + motdBytes.length]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)10);
    		buffer.putInt(motdBytes.length);
    		buffer.put(motdBytes);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send user id
    	public void sendUserId() {
    		//System.out.println("[TX][" + id + "] send connection id");
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[7]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)12).put((byte)3).put((byte)0);
    		buffer.putInt(id);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send connection on (notify this connection of existing connections in the specified channel)
    	public void sendConnectionOn(MooConnection connection, MooChannel channel) {
    		//System.out.println("[TX][" + name + "] send connections in channel " + channel.getName());
    		byte[] connectionNameBytes = connection.getName().getBytes();
    		byte[] ipAddressBytes = connection.getIpAddress().getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[21 + connectionNameBytes.length + ipAddressBytes.length]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)7);
    		buffer.putInt(connection.getId());
    		buffer.putInt(channel.getId());
    		buffer.putInt(channel.getMasterConnection().getId());
    		buffer.putInt(connectionNameBytes.length);
    		buffer.put(connectionNameBytes);
    		buffer.putInt(ipAddressBytes.length);
    		buffer.put(ipAddressBytes);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send connection join (notify this connection of a new connection in the specified session)
    	public void sendConnectionJoin(MooConnection connection, MooChannel channel) {
    		//System.out.println("[TX][" + name + "] send connection join on channel "
    + channel.getName() + ". Connection: " + connection.getName());
    		byte[] connectionNameBytes = connection.getName().getBytes();
    		byte[] ipAddressBytes = connection.getIpAddress().getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[21 + connectionNameBytes.length + ipAddressBytes.length]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)6);
    		buffer.putInt(connection.getId());
    		buffer.putInt(channel.getId());
    		buffer.putInt(channel.getMasterConnection().getId());
    		buffer.putInt(connectionNameBytes.length);
    		buffer.put(connectionNameBytes);
    		buffer.putInt(ipAddressBytes.length);
    		buffer.put(ipAddressBytes);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Notify the client of this connection that it has joined a channel
    	public void sendChannelJoinDetails(MooChannel channel) {
    		//System.out.print("[TX][" + name + "] send channel join details: " + channel.getName());
    		MooConnection masterConnection = channel.getMasterConnection();
    		if (masterConnection == null)
    			masterConnection = this;
    		//System.out.println(" (master connection is " + masterConnection.getName() + ")");
    		byte[] connectionNameBytes = name.getBytes();
    		byte[] ipAddressBytes = ipAddress.getBytes();
    		byte[] channelNameBytes = channel.getName().getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[25 + connectionNameBytes.length
    + ipAddressBytes.length + channelNameBytes.length]).order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)8);
    		buffer.putInt(id);
    		buffer.putInt(channel.getId());
    		buffer.putInt(masterConnection.getId());
    		buffer.putInt(connectionNameBytes.length).put(connectionNameBytes);
    		buffer.putInt(ipAddressBytes.length).put(ipAddressBytes);
    		buffer.putInt(channelNameBytes.length).put(channelNameBytes);
    		//System.out.println(Arrays.toString(buffer.array()));
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send connection left (notify this connection of a connection that has left the specified session)
    	public void sendConnectionLeft(MooConnection connection, MooChannel channel) {
    		//System.out.println("[TX][" + name + "] send connection ["
    + connection.getName() + "] left channel " + channel.getName());
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[13]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)5);
    		buffer.putInt(connection.getId());
    		buffer.putInt(channel.getId());
    		buffer.putInt(channel.getMasterConnection().getId());
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send name change
    	public void sendNameChange(MooConnection connection) {
    		//System.out.println("[TX][" + name + "] send name change. Connection "
    + connection.getId() + " changed name to " + connection.getName());
    		byte[] connectionNameBytes = connection.getName().getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[17 + 2 * connectionNameBytes.length]);
    		buffer.order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)11);
    		buffer.putInt(connection.getId());
    		buffer.putInt(connectionNameBytes.length).put(connectionNameBytes);
    		buffer.putInt(connection.getId());
    		buffer.putInt(connectionNameBytes.length).put(connectionNameBytes);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Send message from the server (i.e. send message from user 0 on channel 0)
    	public void sendMessageFromServer(String text, short subchannel) {
    		//System.out.println("[TX][" + name + "] send message from server on subchannel " + subchannel + ": " + text);
    		byte[] textBytes = text.getBytes();
    		ByteBuffer buffer = ByteBuffer.wrap(new byte[15 + textBytes.length]).order(ByteOrder.LITTLE_ENDIAN);
    		buffer.put((byte)1);
    		buffer.putShort(subchannel);
    		buffer.putInt(0).putInt(0);
    		buffer.putInt(textBytes.length).put(textBytes);
    		server.send(hostKey, buffer.array());
    	}
    
    	// Add a channel to this connection's channel list
    	public void join(MooChannel channel) {
    		channels.add(channel);
    	}
    
    	// Remove a channel from this connection's channel list
    	public void leave(MooChannel channel) {
    		channels.remove(channel);
    	}
    
    	// Disconnect cleanly from all channels
    	public void disconnect() {
    		for (MooChannel channel : channels) {
    			channel.leave(this);
    		}
    		channels.clear();
    		server.disconnect(this);
    	}
    
    	public byte[] getUnprocessedCommandBytes() {
    		return unprocessedCommandBytes;
    	}
    
    	public void processBuffer(ByteBuffer buffer) {
    		try {
    			// If a command was completed and was left in the completed state
    			// due to an empty buffer at the time,
    			// reset the parser with the new command from the buffer.
    			if (parser.getState() == MooCommandParser.State.COMPLETED) {
    				parser.reset(buffer.get());
    			}
    			// Stay in this loop until we have read as much as we can.
    			// Don't just exit on a completion state without doing the completion operation.
    			while (buffer.hasRemaining()) {
    				MooCommandParser.State state = parser.processBuffer(buffer);
    				if (state == MooCommandParser.State.COMPLETED) {
    					switch (parser.getCommand()) {
    					case MESSAGE_TO_CHANNEL:
    						messageToChannel(parser.getText(),
    parser.getChannelId(), parser.getSubchannel());
    						break;
    
    					case MESSAGE_TO_SERVER:
    						messageToServer(parser.getText(), parser.getSubchannel());
    						break;
    
    					case MESSAGE_TO_USER:
    						messageToUser(parser.getText(),parser.getConnectionId(),
    parser.getChannelId(), parser.getSubchannel());
    						break;
    
    					case USER_JOIN_CHANNEL_REQUEST:
    						joinChannelRequest(parser.getText());
    						break;
    
    					case USER_LEFT_CHANNEL:
    						leftChannel(parser.getChannelId());
    						break;
    
    					case PLAYER_NAME_CHANGE:
    						nameChange(parser.getText());
    						break;
    
    					case PLAYER_NAME_SENT:
    						nameSet(parser.getSubcommand1(), parser.getSubcommand2(), parser.getText());
    						break;
    
    					case IGNORE:
    						break;
    					}
    					// Get the next command and reset the parser with it.
    					parser.reset(buffer.get());
    				}
    			}
    		}
    		catch (BufferUnderflowException bue) {
    			// Save any remaining bytes for the next round.
    			if (buffer.hasRemaining()) {
    				unprocessedCommandBytes = new byte[buffer.remaining()];
    				buffer.get(unprocessedCommandBytes);
    			}
    			else {
    				unprocessedCommandBytes = null;
    			}
    		}
    	}
    Code:
    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                         INPUT PROTOCOL METHODS
    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    	// MESSAGE_TO_CHANNEL (command 1)
    	private void messageToChannel(String text, int channelId, short subchannel) {
    		//System.out.println("[RC][" + name + "] message to channel " + channelId
    + " on subchannel " + subchannel + ": " + text);
    		MooChannel channel = server.getChannel(channelId);
    		text = listener.onMessageToChannel(this, text, channel, subchannel);
    		if (text != null) {
    			channel.sendMessage(this, text, subchannel);
    		}
    	}
    
    	// MESSAGE_TO_SERVER (command 2)
    	private void messageToServer(String text, short subchannel) {
    		//System.out.println("[RC][" + name + "] message to server on subchannel " + subchannel + ": " + text);
    		listener.onMessageToServer(this, text, subchannel);
    	}
    
    	// MESSAGE_TO_USER (command 3)
    	private void messageToUser(String text, int connectionId, int channelId, short subchannel) {
    		//System.out.println("[RC][" + name + "] message to user " + connectionId
    + " on subchannel " + subchannel + ": " + text);
    		MooConnection connection = server.getConnection(connectionId);
    		MooChannel channel = server.getChannel(channelId);
    		text = listener.onMessageToUser(this, text, connection, channel, subchannel);
    		if (text != null) {
    			connection.sendMessage(this, text, channel, subchannel);
    		}
    	}
    
    	// USER_JOIN_CHANNEL_REQUEST (command 4)
    	private void joinChannelRequest(String channelName) {
    		//System.out.println("[RC][" + name + "] join channel request: " + channelName);
    		channelName = listener.onChannelJoinRequest(this, channelName);
    		if (channelName != null) {
    			MooChannel channel = server.getChannel(channelName);
    			// Create channel if it doesn't exist
    			if (channel == null) {
    				if (listener.onChannelCreateAttempt(this, channelName)) {
    					channel = server.createChannel(channelName);
    					listener.onChannelCreated(this, channel);
    				}
    			}
    			// Join channel if the listener allows it
    			if (listener.onChannelJoinAttempt(this, channel)) {
    				join(channel);
    				channel.join(this);
    				listener.onChannelJoined(this, channel);
    			}
    		}
    	}
    
    	// USER_LEFT_CHANNEL (command 5)
    	private void leftChannel(int channelId) {
    		//System.out.println("[RC][" + name + "] left channel " + channelId);
    		MooChannel channel = server.getChannel(channelId);
    		if (channel != null) {
    			channel.leave(this);
    			leave(channel);
    			listener.onChannelLeft(this, channel);
    			if (channel.getConnectionCount() == 0) {
    				server.removeChannel(channelId);
    			}
    		}
    	}
    
    	// PLAYER_NAME_CHANGE (command 11)
    	private void nameChange(String newName) {
    		//System.out.println("[RC][" + name + "] name change: " + newName);
    		String oldName = name;
    		if (listener.onNameChangeAttempt(this, newName)) {
    			name = newName;
    			listener.onNameChanged(this, oldName);
    			// Notify all channels
    			for (MooChannel channel : channels)
    				channel.sendNameChange(this);
    		}
    	}
    
    	// PLAYER_NAME_SENT (command 12)
    	private void nameSet(byte subcommand1, byte subcommand2, String name) {
    		//System.out.println("[RC][" + id + "] name set: " + name);
    		if (subcommand1 != 3 || subcommand2 != 0) {
    			throw new IllegalStateException("Syntax error in nameSet command: "
    + subcommand1 + ", " + subcommand2);
    		}
    		if (this.name != null) {
    			//System.out.println("In MooConnection.nameSet: Already found a name: " + this.name);
    			throw new IllegalStateException("The MooConnection with id " + id
    + " and name '" + name +"' is already activated.");
    		}
    		if (listener.onNameSetAttempt(this, name)) {
    			this.name = name;
    			server.addActiveMooConnection(this);
    			listener.onNameSet(this);
    		}
    		else {
    			throw new RuntimeException("MooConnection name \"" + name + "\" rejected.");
    		}
    	}
    }
    .:::.Joshtek.:::.

  7. #17
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export ModuleXNA Export Module
    Fusion 2.5 (Steam)
    Mathias's Avatar
    Join Date
    Jun 2006
    Location
    Copenhagen, Denmark
    Posts
    1,083
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Oh, that's nice! I didn't know Steve had setup a SVN for his implementation.
    Now we just need some proper protocol specifications

  8. #18
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    2,023
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Remember Steve's is licensed under GPL

  9. #19
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    2,023
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    PHP code to get server MOTD (quite useless):
    PHP Code:
    <?PHP
    /*
    Ultra Simple
    MOO+PHP
    MOTD Retriever
    by n_K
    Enjoy ;)
    */

    //Connect Bytes
    $ConnectB[0] = 12;
    $ConnectB[1] = 3;
    $ConnectB[2] = 0;
    $ConnectB[4] = 0;
    $ConnectB[5] = 0;
    $ConnectB[6] = 0;

    //NAME LENGTH
    $ConnectB[3] = 5;
    //NAME HERE
    $ConnectB[7] = 71;
    $ConnectB[8] = 104;
    $ConnectB[9] = 97;
    $ConnectB[10] = 109;
    $ConnectB[11] = 101;
    $ConnectBCurrent 0;
    $ConnectBLoops count($ConnectB);

    while (
    $ConnectBCurrent $ConnectBLoops)
    {
    $ConnectStr .= chr($ConnectB[$ConnectBCurrent]);
    $ConnectBCurrent++;
    }

    $fp fsockopen("SERVER"1203$errno$errstr5);
    if (!
    $fp)
    {
    echo 
    "Failed to connect !";
    }
    else
    {
    fwrite($fp$ConnectStr);

    $contents '';
    $CRec 0;
    $MRec 4;
    while (!
    feof($fp) && $CRec $MRec) {
    $contents .= fread($fp24)."<br>";
    $CRec++;
    }
    fclose($fp);
    }
    $contents explode("<br>"$contents);
    echo 
    "Server MOTD: ".substr($contents[0], 0-(strlen($contents[0])-5));
    ?>

  10. #20
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export ModuleXNA Export Module
    Fusion 2.5 (Steam)
    Mathias's Avatar
    Join Date
    Jun 2006
    Location
    Copenhagen, Denmark
    Posts
    1,083
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: MooClick protokol specifications

    Any updates on this? If not, I wouldn't mind doing this myself

Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Similar Threads

  1. mooclick
    By nick_Peoples in forum The Games Factory 2 - Technical Support
    Replies: 19
    Last Post: 3rd January 2010, 04:45 PM
  2. i really need some help with mooclick
    By Dynamite in forum Multimedia Fusion 2 - Technical Support
    Replies: 13
    Last Post: 15th February 2007, 03:21 PM
  3. New MooClick bug appear (probably 242)
    By Blizna in forum Multimedia Fusion 2 - Technical Support
    Replies: 19
    Last Post: 1st December 2006, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •