Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __history
*.exe
*.dll
bin/*
demo/__recovery/
6 changes: 3 additions & 3 deletions OSCUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function MakeOSCFloat(value: Single): TBytes;
intg := htonl(intg);
{$ENDIF}

Result := IdGlobal.RawToBytes(intg, SizeOf(intg));
Result := TBytes(IdGlobal.RawToBytes(intg, SizeOf(intg)));
end;

function MakeOSCInt(value: Integer): TBytes;
Expand All @@ -178,7 +178,7 @@ function MakeOSCInt(value: Integer): TBytes;
{$ELSE}
value := htonl(value);
{$ENDIF}
Result := IdGlobal.RawToBytes(value, SizeOf(value));
Result := TBytes(IdGlobal.RawToBytes(value, SizeOf(value)));
end;

function MakeOSCString(value: String): TBytes;
Expand Down Expand Up @@ -213,7 +213,7 @@ function UnpackString(Bytes: TBytes; var Offset: Integer): TBytes;
Inc(off);
// Retrieve the string.
SetLength(Result, off - Offset);
IdGlobal.CopyTIdBytes(Bytes, Offset, Result, 0, Length(Result));
Move(Bytes[Offset], Result[0], Length(Result));
// Increase the offset by a multiple of 4.
Offset := off + (4 - off mod 4);
end;
Expand Down
32 changes: 16 additions & 16 deletions demo/Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdSocketHandle, IdUDPServer,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdSocketHandle, IdUDPServer, IdGlobal,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient, Vcl.StdCtrls;

type
Expand All @@ -23,7 +23,7 @@ TForm1 = class(TForm)
SendArgumentsEdit: TEdit;
SendButton: TButton;
procedure FUDPServerUDPRead(AThread: TIdUDPListenerThread; AData:
TArray<System.Byte>; ABinding: TIdSocketHandle);
TIdBytes; ABinding: TIdSocketHandle);
procedure SendButtonClick(Sender: TObject);
private
{ Private declarations }
Expand All @@ -41,16 +41,16 @@ implementation
{$R *.dfm}

procedure TForm1.FUDPServerUDPRead(AThread: TIdUDPListenerThread; AData:
TArray<System.Byte>; ABinding: TIdSocketHandle);
TIdBytes; ABinding: TIdSocketHandle);
var
packet: TOSCPacket;
msg: TOSCMessage;
i: Integer;
typetag, arg: String;
packet : TOSCPacket;
msg : TOSCMessage;
i : Integer;
typetag, arg : String;
formatSettings: TFormatSettings;
begin
packet := TOSCpacket.Unpack(AData, Length(AData));
msg := packet.MatchAddress(ReceiveAddressEdit.Text);
packet := TOSCPacket.Unpack(TBytes(AData), Length(AData));
msg := packet.MatchAddress(ReceiveAddressEdit.Text);
if Assigned(msg) then
begin
msg.Decode;
Expand All @@ -76,23 +76,23 @@ procedure TForm1.FUDPServerUDPRead(AThread: TIdUDPListenerThread; AData:

procedure TForm1.SendButtonClick(Sender: TObject);
var
msg: TOSCMessage;
msg : TOSCMessage;
bundle: TOSCBundle;
begin
//create a bundle
// create a bundle
bundle := TOSCBundle.Create(nil);

//create a message
// create a message
msg := TOSCMessage.Create(SendAddressEdit.Text);

//add arguments to the message
// add arguments to the message
msg.AddString(SendArgumentsEdit.Text);

//add message to the bundle
// add message to the bundle
bundle.Add(msg);

//send bundle as bytes
FUDPClient.SendBuffer(bundle.ToOSCBytes);
// send bundle as bytes
FUDPClient.SendBuffer(TIdBytes(bundle.ToOSCBytes));
end;

end.