Skip to content

Commit

Permalink
fix #40, change the way messages are queued for the SignalR connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jrusbatch committed Apr 30, 2012
1 parent f7e3a31 commit 248d808
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -12,4 +12,6 @@ _ReSharper.*
*.resharper
packages/
*.ncrunchsolution
*.DotSettings
*.DotSettings
UpgradeLog*.xml
_Upgrade*
33 changes: 24 additions & 9 deletions Web/Assets/js/compilify.js
Expand Up @@ -20,12 +20,22 @@

var timer,
isConnected = false,
messageQueue = [],
conn = $.connection(url),
opts = _.defaults(options, {
timeout: 30000,
onReceived: $.noop
});


function onStarted() {
var next;
while ((next = messageQueue.shift()) !== undefined) {
conn.send(next);
}

isConnected = true;
}

function onTimeout() {
conn.stop();
isConnected = false;
Expand All @@ -42,17 +52,19 @@
});

conn.received(opts.onReceived);

conn.reconnected(function() {
console.log("Reconnected!");
});

return {
send: function (data) {
if (isConnected === true) {
conn.send(data);
}
else {
conn.start(function() {
isConnected = true;
conn.send(data);
});
messageQueue.push(data);
conn.start(onStarted);
}
}
};
Expand Down Expand Up @@ -111,14 +123,17 @@

for (var index in msg.data) {
var error = msg.data[index];
var loc = error.Location;

var start = error.Location.StartLinePosition;
var end = error.Location.EndLinePosition;
var file = loc.FileName;

var start = loc.StartLinePosition;
var end = loc.EndLinePosition;

var markStart = { line: start.Line, ch: start.Character };
var markEnd = { line: end.Line, ch: end.Character };
var mark = Compilify[error.Location.FileName].markText(markStart, markEnd, 'compilation-error');

var mark = Compilify[file].markText(markStart, markEnd, 'compilation-error');

markedErrors.push(mark);

Expand Down
12 changes: 11 additions & 1 deletion Web/Web.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -18,6 +19,10 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<JSLintSkip>\Assets\js\vendor\</JSLintSkip>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -295,8 +300,13 @@
<Name>Core</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

0 comments on commit 248d808

Please sign in to comment.