Skip to content

Commit

Permalink
MCComm API and Channel Expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
SineVector241 committed Jul 6, 2024
1 parent 2a3d6e9 commit 78a8a45
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 5 deletions.
4 changes: 4 additions & 0 deletions VoiceCraft.Core/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
{
public class Channel
{
private bool locked;

public string Name { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public bool Locked { get => locked || Hidden; set => locked = value; }
public bool Hidden { get; set; } = false;
public ChannelOverride? OverrideSettings { get; set; }
}

Expand Down
9 changes: 9 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/ChannelAdd.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class ChannelAdd : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.ChannelAdd;
public string PlayerId { get; set; } = string.Empty;
public byte ChannelId { get; set; } = 0; //0 For Main;
}
}
2 changes: 1 addition & 1 deletion VoiceCraft.Core/Packets/MCComm/ChannelMove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class ChannelMove : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.ChannelMove;
public string PlayerId { get; set; } = string.Empty;
public int ChannelId { get; set; } = 0; //Set to -1 to disconnect the participant from the channel.
public byte ChannelId { get; set; } = 0; //0 For Main.
}
}
9 changes: 9 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/ChannelRemove.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class ChannelRemove : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.ChannelRemove;
public string PlayerId { get; set; } = string.Empty;
public byte ChannelId { get; set; } = 0; //0 For Main. If participant is removed from another channel, they will automatically be added to main. you cannot remove participants that are only in main.
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/DeafenParticipant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class DeafenParticipant : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.DeafenParticipant;
public string PlayerId { get; set; } = string.Empty;
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/GetParticipantBitmask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class GetParticipantBitmask : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.GetParticipantBitmask;
public byte Bitmask { get; set; }
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/MuteParticipant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class MuteParticipant : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.MuteParticipant;
public string PlayerId { get; set; } = string.Empty;
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/SetParticipantBitmask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class SetParticipantBitmask : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.SetParticipantBitmask;
public byte Bitmask { get; set; }
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/UndeafenParticipant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class UndeafenParticipant : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.UndeafenParticipant;
public string PlayerId { get; set; } = string.Empty;
}
}
8 changes: 8 additions & 0 deletions VoiceCraft.Core/Packets/MCComm/UnmuteParticipant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VoiceCraft.Core.Packets.MCComm
{
public class UnmuteParticipant : MCCommPacket
{
public override byte PacketId => (byte)MCCommPacketTypes.UnmuteParticipant;
public string PlayerId { get; set; } = string.Empty;
}
}
17 changes: 14 additions & 3 deletions VoiceCraft.Core/Packets/MCCommPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ public enum MCCommPacketTypes : byte
Deny,
Bind,
Update,
UpdateSettings,
AckUpdate,
GetSettings,
RemoveParticipant,
UpdateSettings,

//Participant Stuff
DisconnectParticipant,
SetParticipantBitmask,
GetParticipantBitmask,
MuteParticipant,
UnmuteParticipant,
DeafenParticipant,
UndeafenParticipant,

ChannelMove,
AckUpdate
ChannelAdd,
ChannelRemove
}
}
2 changes: 2 additions & 0 deletions VoiceCraft.Server/Data/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public static Properties LoadProperties()
Logger.LogToConsole(LogType.Success, $"Successfully created file {PropertiesDirectory}.", "Properties");
}

ServerProperties.Channels.Insert(0, new Channel() { Name = "Main", Hidden = true }); //Adds main channel.

if (ServerProperties.VoiceCraftPortUDP < 1025 || ServerProperties.MCCommPortTCP < 1025)
throw new Exception("One of the ports is lower than the minimum port 1025!");
if (ServerProperties.VoiceCraftPortUDP > 65535 || ServerProperties.MCCommPortTCP > 65535)
Expand Down
4 changes: 3 additions & 1 deletion VoiceCraft.Server/Data/VoiceCraftParticipant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class VoiceCraftParticipant : Participant
public bool Binded { get; set; }
public bool ClientSided { get; set; }
public bool ServerMuted { get; set; }
public Channel? Channel { get; set; }
public bool ServerDeafened { get; set; }
public List<Channel> Channels { get; set; } = new List<Channel>();

//Minecraft Data
public Vector3 Position { get; set; }
Expand All @@ -19,6 +20,7 @@ public class VoiceCraftParticipant : Participant
public bool InWater { get; set; }
public string EnvironmentId { get; set; } = string.Empty;
public string MinecraftId { get; set; } = string.Empty;
public byte ChecksBitmask { get; set; } = byte.MaxValue; //All bits are set. 1111 1111

public VoiceCraftParticipant(string name) : base(name)
{
Expand Down

0 comments on commit 78a8a45

Please sign in to comment.