Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Move Cpp Client to main repo #1703

Merged
merged 8 commits into from
Mar 29, 2018
Merged

Move Cpp Client to main repo #1703

merged 8 commits into from
Mar 29, 2018

Conversation

BrennanConroy
Copy link
Member

No description provided.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presuming no code changes since the last PR on the old repo and that it isn't wired in to the build yet, I'm good.


This folder contains a C++ client for ASP.NET Core SignalR.

**This is an experimental project right now**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it even clearer and add "There are no plans to ship this client at this time"

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://media0.giphy.com/media/ihWcaj6R061wc/giphy.gif

</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{BEC3FEA2-DD32-4B55-B27F-64A5F3DBBB46}</ProjectGuid>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flashbacks D:

@BrennanConroy
Copy link
Member Author

OSX 10.12, Ubuntu 16.04, and Windows all pass, so it must be good :trollface:

@Eilon
Copy link
Member

Eilon commented Mar 23, 2018

So we don't need the other repo?

@BrennanConroy
Copy link
Member Author

Correct, but I still need to copy the issues over before you delete it

Copy link
Contributor

@moozzyk moozzyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think you would get further and quicker if you take the old client and remove things that are not needed.
Also, you will get quite a lot of test coverage for free.

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at files in folder here: https://github.com/SignalR/SignalR-Client-Cpp/tree/dev/Build - they help avoid duplication. I don't want to go too far but I think you will want to copy a lot of this. Not only because they worked but they also use compiler settings required/recommended by security folks.

web::http::client::http_client client(url);

web::http::http_request request;
request.set_method(L"POST");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think cross plat from the very beginning or you will have a lot of work later. Start from using _XPLATSTR or _U for string literals

{
mUrl = url;
mTransport = new WebSocketsTransport(mUrl);
mTransport->OnReceived([&](const utility::string_t& messages)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't capture like this - this will crash very hard. I did not read the code very carefully but I think this lambda can outlive the connection and all your m* variables will cause segfaults. There is a reason while the old SignalR C++ client used shared_ptr all over the place (https://github.com/SignalR/SignalR-Client-Cpp/blob/dev/src/signalrclient/connection_impl.cpp#L96). Read more on this in my post https://blog.3d-logic.com/2014/12/28/c-async-development-not-only-for-for-c-developers-part-ii-lambda-functions-the-most-common-pitfalls/
(because you are using Casablanca consider reading entire series: https://blog.3d-logic.com/category/cpprestsdk/ - it is basically my learnings from writing the SignalR client. Sadly, I have never written the last two posts).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm going to be using shared_ptr later, this was a quick, get things working

}
else
{
//???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw - invalid URL

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn" version="2.9.1" targetFramework="native" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dat package name.

@@ -0,0 +1,34 @@
// Copyright (c) .NET Foundation. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the ClientSample folder pascal case?

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why signalrlib and not lib or just signalr?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually should be libsignalr for mac and linux

@analogrelay
Copy link
Contributor

Wow

image

So... I presume a lot of this is the old client copied over?

Copy link
Member

@Eilon Eilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve the third-party-notices change.

@JamesNK
Copy link
Member

JamesNK commented Mar 28, 2018

A lot of files are missing a copyright header

@analogrelay
Copy link
Contributor

BOOM!

@BrennanConroy
Copy link
Member Author

Which files are missing copyright?

@JamesNK
Copy link
Member

JamesNK commented Mar 29, 2018

A saw in a quick scan:

clients/cpp/samples/HubConnectionSample/HubConnectionSample.cpp
clients/cpp/samples/PersistentConnectionSample/PersistentConnectionSample.cpp
clients/cpp/samples/PersistentConnectionSample/stdafx.cpp
clients/cpp/samples/PersistentConnectionSample/stdafx.h
clients/cpp/samples/SignalRServer/ChatHub.cs
clients/cpp/samples/SignalRServer/EchoConnection.cs
clients/cpp/samples/SignalRServer/Properties/AssemblyInfo.cs

@BrennanConroy
Copy link
Member Author

I guess we can put copyright in samples...

Copy link
Member

@Eilon Eilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-signing off on licenses. Thanks 😄

@BrennanConroy
Copy link
Member Author

100% not related to this PR, but still interesting

The active test run was aborted. Reason: Unhandled Exception: Unhandled Exception: System.InvalidOperationException: Another continuation was already registered.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowMultipleContinuationsException()
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.OnCompleted(Action`1 continuation, Object state, Int16 token, ValueTaskSourceOnCompletedFlags flags)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AwaitUnsafeOnCompleted[TAwaiter,TStateMachine](TAwaiter& awaiter, TStateMachine& stateMachine)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ThreadPoolWorkQueue.Dispatch()System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: state
   at System.Threading.Tasks.ValueTask`1.ValueTaskSourceTask.<>c.<.cctor>b__4_0(Object state)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.InvokeContinuation(Action`1 continuation, Object state, Boolean forceAsync)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs _)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionCallback(Int32 bytesTransferred, SocketFlags flags, SocketError socketError)
   at System.Net.Sockets.SocketAsyncEventArgs.TransferCompletionCallbackCore(Int32 bytesTransferred, Byte[] socketAddress, Int32 socketAddressSize, SocketFlags receivedFlags, SocketError socketError)
   at System.Net.Sockets.SocketAsyncContext.BufferMemoryReceiveOperation.InvokeCallback(Boolean allowPooling)
   at System.Net.Sockets.SocketAsyncContext.AsyncOperation.<>c.<TryCancel>b__17_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

@davidfowl
Copy link
Member

@BrennanConroy we're on a thread with the BCL about this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants