-
Notifications
You must be signed in to change notification settings - Fork 77
Typed command ids #1372
Typed command ids #1372
Changes from all commits
58fe731
c5ae414
00de3e5
cdc1d82
34f2aa7
3a880aa
fe8a59e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
|
||
namespace Improbable.Gdk.Core.Commands | ||
{ | ||
public readonly struct CommandRequestId : IEquatable<CommandRequestId>, IComparable<CommandRequestId> | ||
{ | ||
public readonly long Raw; | ||
|
||
public CommandRequestId(long requestId) | ||
{ | ||
Raw = requestId; | ||
} | ||
|
||
public static bool operator ==(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return left.Equals(right); | ||
} | ||
|
||
public static bool operator !=(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return !left.Equals(right); | ||
} | ||
|
||
public static bool operator <(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return left.CompareTo(right) < 0; | ||
} | ||
|
||
public static bool operator >(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return left.CompareTo(right) > 0; | ||
} | ||
|
||
public static bool operator <=(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return left.CompareTo(right) <= 0; | ||
} | ||
|
||
public static bool operator >=(CommandRequestId left, CommandRequestId right) | ||
{ | ||
return left.CompareTo(right) >= 0; | ||
} | ||
|
||
public bool Equals(CommandRequestId other) | ||
{ | ||
return Raw == other.Raw; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is CommandRequestId other && Equals(other); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return Raw.GetHashCode(); | ||
} | ||
|
||
public int CompareTo(CommandRequestId other) | ||
{ | ||
return Raw.CompareTo(other.Raw); | ||
} | ||
} | ||
|
||
public readonly struct InternalCommandRequestId : IEquatable<InternalCommandRequestId>, IComparable<InternalCommandRequestId> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are the same data wise, but 1 is an id the GDK generates when you schedule a command to be send. And the internal ID is the ID the worker SDK returns when the command is actually send over the network. |
||
{ | ||
public readonly long Raw; | ||
|
||
public InternalCommandRequestId(long requestId) | ||
{ | ||
Raw = requestId; | ||
} | ||
|
||
public static bool operator ==(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return left.Equals(right); | ||
} | ||
|
||
public static bool operator !=(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return !left.Equals(right); | ||
} | ||
|
||
public static bool operator <(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return left.CompareTo(right) < 0; | ||
} | ||
|
||
public static bool operator >(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return left.CompareTo(right) > 0; | ||
} | ||
|
||
public static bool operator <=(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return left.CompareTo(right) <= 0; | ||
} | ||
|
||
public static bool operator >=(InternalCommandRequestId left, InternalCommandRequestId right) | ||
{ | ||
return left.CompareTo(right) >= 0; | ||
} | ||
|
||
public bool Equals(InternalCommandRequestId other) | ||
{ | ||
return Raw == other.Raw; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is InternalCommandRequestId other && Equals(other); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return Raw.GetHashCode(); | ||
} | ||
|
||
public int CompareTo(InternalCommandRequestId other) | ||
{ | ||
return Raw.CompareTo(other.Raw); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Improbable.Worker.CInterop; | ||
|
||
namespace Improbable.Gdk.Core.Commands | ||
{ | ||
public interface ICommandDiffDeserializer | ||
{ | ||
void AddRequestToDiff(CommandRequestOp op, ViewDiff diff); | ||
void AddResponseToDiff(CommandResponseOp op, ViewDiff diff, CommandMetaData commandMetaData); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... does this need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For us no, but I wanted to keep this public in case someone used the command ID's for something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then they can use this right? It has equality and comparison operators. Like why would you want the raw number over the wrapper struct?