• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

SharpCraft TCP

Status
Not open for further replies.
Hi,
here is a TCP Plugin I am working at the moment.
Uses SharpCraft 1.2.4.0.
Every message send is escaped with a new line character.

Example:
attachment.php


New Natives
JASS:
//TCP
public native TCPConnectionCreate(string ip, int port) returns integer
public native TCPConnectionIsConnected(int id) returns boolean
public native TCPConnectionSend(int id, string message)
public native TCPConnectionHasMessage(int id) returns boolean
public native TCPConnectionReadMessage(int id) returns string
public native TCPConnectionClose(int id)

Wurst Client Code
JASS:
int connection

//Send messages entered as chat message
function sendMessage()
	TCPConnectionSend(connection,GetEventPlayerChatString())

//Print messages recieved from the server
function recieveMessage()
	while(TCPConnectionHasMessage(connection))
		print(TCPConnectionReadMessage(connection))

init
	//Create Connection
	connection = TCPConnectionCreate("127.0.0.1", 5000)
	
	//If Connection was succesfull
	if(TCPConnectionIsConnected(connection))
		print("Connection to Server succesfull!")
		
		CreateTrigger()
			..registerTimerEvent(0.1,true)
			..addAction(function recieveMessage)
			
		CreateTrigger()
			..registerPlayerChatEvent(Player(0), "", false)
			..addAction(function sendMessage)
	else 
		print("Connection to Server failed!")

Java Server:
JASS:
public class Server {
	private static int portNumber=5000;
	
	public static void main(String args[]) {		
		try{
	        ServerSocket serverSocket = new ServerSocket(portNumber);
	        System.out.println("Started Server");
	        
	        Socket clientSocket = serverSocket.accept();
	        System.out.println("Connected");
	        
	        BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(),"UTF-8"));
	        OutputStreamWriter writer = new OutputStreamWriter(clientSocket.getOutputStream(),"UTF-8");
	        PrintWriter out =new PrintWriter(writer, true);
	        
	        out.println("Hello Client!");
	        
	        String inputLine;
	        while ((inputLine = in.readLine()) != null) {
	            System.out.println("Received: " + inputLine);
	            out.println("Server received: " + inputLine);
	        }
		}catch(Exception e){
			System.out.println("Connection Closed");
		}
	}
}
 

Attachments

  • ExampleMessages.jpg
    ExampleMessages.jpg
    182.3 KB · Views: 754
  • TCPPlugin.rar
    TCPPlugin.rar
    1.4 KB · Views: 138
any chance there will be an implementation that would allow say 1 player with the mod and 10 players with the vanilla client to be in the same game..?

this looks very juicy...
but excluding all vanilla players is way too expensive for a real mapper imo.
 
Status
Not open for further replies.
Back
Top