Skip to content

Commit

Permalink
Fixed disconnects not being called correctly
Browse files Browse the repository at this point in the history
- Moved to 0.3.3
  • Loading branch information
alandoherty committed Dec 4, 2018
1 parent e4e119b commit 5324dc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions samples/Example.Minecraft/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@ public void Despawn() {
List<Task> sendTasks = new List<Task>();

foreach (Player p in _world.Players) {
ClassicPacket spawnPacket = new ClassicPacket();
spawnPacket.Id = PacketId.DespawnPlayer;
if (p.Connection.IsConnected) {
ClassicPacket spawnPacket = new ClassicPacket();
spawnPacket.Id = PacketId.DespawnPlayer;

PacketWriter spawnWriter = new PacketWriter();
spawnWriter.WriteSByte(this == p ? (sbyte)-1 : ID);
PacketWriter spawnWriter = new PacketWriter();
spawnWriter.WriteSByte(this == p ? (sbyte)-1 : ID);

p.Connection.Queue(spawnPacket);
try {
p.Connection.Queue(spawnPacket);
} catch (ObjectDisposedException) { }
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ProtoSocket/ProtoSocket.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard1.3</TargetFramework>
<Authors>Alan Doherty &amp; WIFIPLUG Ltd</Authors>
<Company>Alan Doherty</Company>
<Version>0.3.2</Version>
<Version>0.3.3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>A networking library for frame-based, performant asynchronous sockets on .NET Core</Description>
<Copyright>Alan Doherty 2018</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions src/ProtoSocket/ProtocolPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,11 @@ private void Abort(string closeReason = null, Exception closeException = null) {
// dispose client
OnStateChanged(new PeerStateChangedEventArgs<TFrame>() {
OldState = _state,
NewState = ProtocolState.Disconnected
NewState = ProtocolState.Disconnecting
});

// set disconnected
_state = ProtocolState.Disconnected;
_state = ProtocolState.Disconnecting;

// remove all subscriptions mark as error
lock(_subscriptions) {
Expand Down

0 comments on commit 5324dc7

Please sign in to comment.