Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime parties #50

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ To run a specific test, pass the fully qualified name of the method to `dotnet t
dotnet test --filter "Nakama.Tests.Api.GroupTest.ShouldPromoteAndDemoteUsers"
```

### License
If you'd like to attach a Visual Studio debugger to a test, set `VSTEST_HOST_DEBUG` to `true` in your shell environment and run `dotnet test`. Attach the debugger to the process identified by the console.

### Licenses

This project is licensed under the [Apache-2 License](https://github.com/heroiclabs/nakama-dotnet/blob/master/LICENSE).

Expand Down
14 changes: 7 additions & 7 deletions src/Nakama/IMatchState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ internal class MatchState : IMatchState

[DataMember(Name = "match_id"), Preserve] public string MatchId { get; set; }

public long OpCode => Convert.ToInt64(_opCode);
[DataMember(Name = "op_code"), Preserve] public string _opCode { get; set; }
public long OpCode => Convert.ToInt64(OpCodeField);
[DataMember(Name = "op_code"), Preserve] public string OpCodeField { get; set; }

public byte[] State => _state == null ? NoBytes : Convert.FromBase64String(_state);
[DataMember(Name = "data"), Preserve] public string _state { get; set; }
public byte[] State => StateField == null ? NoBytes : Convert.FromBase64String(StateField);
[DataMember(Name = "data"), Preserve] public string StateField { get; set; }

public IUserPresence UserPresence => _userPresence;
[DataMember(Name = "presence"), Preserve] public UserPresence _userPresence { get; set; }
public IUserPresence UserPresence => UserPresenceField;
[DataMember(Name = "presence"), Preserve] public UserPresence UserPresenceField { get; set; }

public override string ToString()
{
return $"MatchState(MatchId='{MatchId}', OpCode={OpCode}, State='{_state}', UserPresence={UserPresence})";
return $"MatchState(MatchId='{MatchId}', OpCode={OpCode}, State='{State}', UserPresence={UserPresence})";
}
}
}
54 changes: 54 additions & 0 deletions src/Nakama/IParty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;

namespace Nakama
{
/// <summary>
/// Incoming information about a party.
/// </summary>
public interface IParty
{
/// <summary>
/// The unique party identifier.
/// </summary>
string Id { get; }

/// <summary>
/// True, if the party is open to join.
/// </summary>
bool Open { get; }

/// <summary>
/// The maximum number of party members.
/// </summary>
int MaxSize { get; }

/// <summary>
/// The current user in this party. i.e. Yourself.
/// </summary>
IUserPresence Self { get; }

/// <summary>
/// The current party leader.
/// </summary>
IUserPresence Leader { get; }

/// <summary>
/// All members currently in the party.
/// </summary>
IEnumerable<IUserPresence> Presences { get; }
}
}
27 changes: 27 additions & 0 deletions src/Nakama/IPartyClose.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Nakama
{
/// <summary>
/// End a party, kicking all party members and closing it.
/// </summary>
public interface IPartyClose
{
/// <summary>
/// The ID of the party to close.
/// </summary>
string PartyId { get; }
}
}
42 changes: 42 additions & 0 deletions src/Nakama/IPartyData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Nakama
{
/// <summary>
/// Incoming party data delivered from the server.
/// </summary>
public interface IPartyData
{
/// <summary>
/// The ID of the party.
/// </summary>
string PartyId { get; }

/// <summary>
/// A reference to the user presence that sent this data, if any.
/// </summary>
IUserPresence Presence { get; }

/// <summary>
/// The operation code the message was sent with.
/// </summary>
long OpCode { get; }

/// <summary>
/// Data payload, if any.
/// </summary>
byte[] Data { get; }
}
}
34 changes: 34 additions & 0 deletions src/Nakama/IPartyJoinRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;

namespace Nakama
{
/// <summary>
/// Incoming notification for one or more new presences attempting to join the party.
/// </summary>
public interface IPartyJoinRequest
{
/// <summary>
/// The ID of the party to get a list of join requests for.
/// </summary>
string PartyId { get; }

/// <summary>
/// Presences attempting to join, or who have joined.
/// </summary>
IEnumerable<IUserPresence> Presences { get; }
}
}
32 changes: 32 additions & 0 deletions src/Nakama/IPartyLeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Nakama
{
/// <summary>
/// Announcement of a new party leader.
/// </summary>
public interface IPartyLeader
{
/// <summary>
/// The ID of the party to announce the new leader for.
/// </summary>
string PartyId { get; }

/// <summary>
/// The presence of the new party leader.
/// </summary>
IUserPresence Presence { get; }
}
}
32 changes: 32 additions & 0 deletions src/Nakama/IPartyMatchmakerTicket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Nakama
{
/// <summary>
/// A response from starting a new party matchmaking process.
/// </summary>
public interface IPartyMatchmakerTicket
{
/// <summary>
/// The ID of the party.
/// </summary>
string PartyId { get; }

/// <summary>
/// The ticket that can be used to cancel matchmaking.
/// </summary>
string Ticket { get; }
}
}
39 changes: 39 additions & 0 deletions src/Nakama/IPartyPresenceEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2021 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;

namespace Nakama
{
/// <summary>
/// Presence update for a particular party.
/// </summary>
public interface IPartyPresenceEvent
{
/// <summary>
/// The ID of the party.
/// </summary>
string PartyId { get; }

/// <summary>
/// The user presences that have just joined the party.
/// </summary>
IEnumerable<IUserPresence> Joins { get; }

/// <summary>
/// The user presences that have just left the party.
/// </summary>
IEnumerable<IUserPresence> Leaves { get; }
}
}
Loading