Announcement

Collapse
No announcement yet.

FSocket and Endpoints!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    FSocket and Endpoints!

    I have implemented the following code with success:
    Code:
    bool UMyGameInstance::StartChatConnection(const FString & SocketName, const FString & IPAddress, const int32 Port, bool& connected)
    {
        this->ChatSocket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, SocketName, false);
        if (this->ChatSocket)
        {
            // FString address = TEXT("http://localhost:7776/LiveChat?Name=Ben");
    
            FIPv4Address ip(127, 0, 0, 1);    
            TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
            addr->SetAnyAddress();
            addr->SetIp(ip.Value);
            addr->SetPort(7776);
    
            connected = this->ChatSocket->Connect(*addr);
    
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("StartChatConnection>> Socket Created! ~> %s %d"), *IPAddress, Port));
        }
        else
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("StartChatConnection>> Socket could not be created! ~> %s %d"), *IPAddress, Port));
        }
        return false;
    }
    This connects to my C# Socket Server on localhost and port 7776, what i want to do though is pass the /LiveChat path to the Connection somehow as I have multiple handlers implemented on the server. If all else fails I can opt for multiple socket servers on separate ports but would like to try this first. Not sure if what I am attempting to do is making sense so please ask away if anything is unclear.

    Always Active Technologies
    {Binary_Shepherd}
    /** the only losers are those who give up. */

    #2
    I have disregarded the attempt to use web sockets and have opted for normal sockets instead. The above example works quite well with plain socket server on C# \/

    Always Active Technologies
    {Binary_Shepherd}
    /** the only losers are those who give up. */

    Comment

    Working...
    X