1
0
Fork 0

[server] Fix ripplespace representation

This commit is contained in:
Starbeamrainbowlabs 2017-04-29 13:43:19 +01:00
parent b21608d261
commit d79fdc8d04
5 changed files with 18 additions and 62 deletions

View File

@ -410,8 +410,10 @@ namespace Nibriboard.Client
protected void handleChunkUpdateEvent(object sender, ChunkUpdateEventArgs eventArgs)
{
Chunk sendingChunk = sender as Chunk;
Log.WriteLine("[NibriClient#{0}] Sending chunk update for {1}", Id, sendingChunk.Location);
ChunkUpdateMessage clientNotification = new ChunkUpdateMessage() {
Chunks = new List<Chunk>() { sender as Chunk }
Chunks = new List<Chunk>() { sendingChunk }
};
Send(clientNotification);
}

View File

@ -7,7 +7,7 @@ window.panzoom = require("pan-zoom");
// Our files
import RippleLink from './RippleLink';
import ViewportSyncer from './ViewportSyncer';
import CursorSyncer from './CursorSyncer';
import OtherClient from './OtherClient';
import Pencil from './Pencil';
import { get } from './Utilities';
@ -166,7 +166,7 @@ class BoardWindow extends EventEmitter
}).bind(this))
// Keep the server up to date on our viewport and cursor position
this.viewportSyncer = new ViewportSyncer(this.rippleLink, this.cursorUpdateFrequency)
this.cursorSyncer = new CursorSyncer(this.rippleLink, this.cursorUpdateFrequency)
// RippleLink message bindings

View File

@ -1,56 +0,0 @@
"use strict";
class CursorSyncer
{
constructor(inRippleLink, syncFrequency)
{
// The ripple link we should send the cursor updates down
this.rippleLink = inRippleLink;
// The target frequency in fps at we should send sursor updates.
this.cursorUpdateFrequency = syncFrequency;
// Register ourselves to start sending cursor updates once the ripple
// link connects
this.rippleLink.on("connect", this.setup.bind(this));
}
setup()
{
// The last time we sent a cursor update to the server.
this.lastCursorUpdate = 0;
document.addEventListener("mousemove", (function(event) {
this.cursorPosition = {
X: event.clientX,
Y: event.clientY
};
setTimeout((function() {
// Throttle the cursor updates we send to the server - a high
// update frequency here will just consume bandwidth and is only
// noticable if you have a good connection
if(+new Date() - this.lastCursorUpdate < 1 / this.cursorUpdateFrequency)
return false;
// Update the server on the mouse's position
this.sendCursorUpdate();
this.lastFrameStart = +new Date();
}).bind(this), 1 / this.cursorUpdateFrequency);
}).bind(this));
this.sendCursorUpdate();
}
sendCursorUpdate()
{
// Update the server on the mouse's position
this.rippleLink.send({
"Event": "CursorPosition",
"AbsCursorPosition": this.cursorPosition
});
}
}
export default CursorSyncer;

View File

@ -55,7 +55,7 @@ namespace Nibriboard.RippleSpace
public readonly int Size;
/// <summary>
/// The location of this chunk chunk on the plane.
/// The location of this chunk, in chunk-space, on the plane.
/// </summary>
public readonly ChunkReference Location;
@ -170,7 +170,7 @@ namespace Nibriboard.RippleSpace
if (newLine.SpansMultipleChunks == true)
throw new ArgumentException("Error: A line you tried to add spans multiple chunks.", $"newLines[{i}]");
if (newLine.ContainingChunk != Location)
if (!newLine.ContainingChunk.Equals(Location))
throw new ArgumentException($"Error: A line you tried to add isn't in this chunk ({Location}).", $"newLine[{i}]");
lines.Add(newLine);
@ -214,5 +214,15 @@ namespace Nibriboard.RippleSpace
}
#endregion
public override string ToString()
{
return string.Format(
"Chunk{0} {1} - {2} lines",
CouldUnload ? "!" : ":",
Location,
lines.Count
);
}
}
}

View File

@ -195,7 +195,7 @@ namespace Nibriboard.RippleSpace
return;
}
Log.WriteLine("[Plane {0}] Chunk at {1} {2} updated", Name, updatingChunk.Location, eventArgs.UpdateType);
Log.WriteLine("[Plane {0}] Chunk at {1} updated because {2}", Name, updatingChunk.Location, eventArgs.UpdateType);
// Make the chunk update bubble up to plane-level
OnChunkUpdate(sender, eventArgs);