Skip to content

Instantly share code, notes, and snippets.

View ryanjon2040's full-sized avatar
😃
@EpicGames UnrealEngine FTW

Satheesh (ryanjon2040) ryanjon2040

😃
@EpicGames UnrealEngine FTW
View GitHub Profile
@ryanjon2040
ryanjon2040 / YourGameInstance.cpp
Last active May 6, 2017 07:51
Example source file for pinging EC2 UDp server http://wp.me/p2fInN-tA
void UYourGameInstance::CheckIfServerIsOnline(FString ServerIP, FString ServerPort)
{
/* First bind our OnServerCheckFinished function to PingResult.
* When we get any reply from UDP server PingResult will be called
* and when PingResult is called the binded method (OnServerCheckFinished) is also called. */
PingReult.BindUObject(this, &UYourGameInstance::OnServerCheckFinished);
/* Our UDP server ip (public ip) and port we have to ping.
* Port should be the exact same port we defined on UDP server node.js file on EC2 server */
const FString Address = FString::Printf(TEXT("%s:%d"), *ServerIP, ServerPort);
@ryanjon2040
ryanjon2040 / YourGameInstance.h
Last active May 12, 2017 05:42
Example header file for pinging EC2 UDp server http://wp.me/p2fInN-tA
#include "Icmp.h"
/* Delegate to bind our custom function when we receive a reply from our EC2 UDP server */
FIcmpEchoResultDelegate PingReult;
/* Sends a UDP echo to the given server and waits for a reply */
UFUNCTION(BlueprintCallable)
void CheckIfServerIsOnline(FString ServerPublicIP, FString ServerPort);
/* Delegate called when we get a reply from our EC2 UDP server */
@ryanjon2040
ryanjon2040 / MyUDPServer.js
Last active September 22, 2021 09:06
Node.js udp server example http://wp.me/p2fInN-tA
// port to listen to
var PORT = xxxxx; // Change to your port number
// x's should be replaced with your EC2 private ip
var HOST = 'ip-xxx-xx-xx-xxx.your-region.compute.internal';
// Load datagram module
var dgram = require('dgram');
// Create a new instance of dgram socket