background preloader

ServiceStack

Facebook Twitter

PersistentConnection · SignalR/SignalR Wiki. Persistent Connections (Server) A PersistentConnection is the base class that has an api for exposing a SignalR service over http.

PersistentConnection · SignalR/SignalR Wiki

To create a new endpoint. Create a new class that derives from PersistentConnection. public class MyEndPoint : PersistentConnection { } To make this endpoint accessible, add a route to Application_Start (or something similar): This will expose /echo as a SignalR endpoint. PersistentConnection API Task OnConnected(IRequest request, string connectionId) Called when a new connection is made. request - The request associated with this connection.connectionId - The id of the new connection. Example public class MyEndPoint : PersistentConnection { protected override Task OnConnected(IRequest request, string connectionId) { return Connection.Broadcast("Connection " + connectionId + " connected"); } } Task OnReconnected(IRequest request, IEnumerable groups, string connectionId) Called when a connection is restored.

Called when data is received on the connection. IConnection API. SignalR, Filters and ServiceStack - StrathWeb. I recently blogged about a technique of integrating SignalR with ASP.NET Web API through the use of action filters.

SignalR, Filters and ServiceStack - StrathWeb

A few people have asked, whether this approach (and SignalR now being part of Microsoft’s ASP.NET product group after all) works with other frameworks. And the answer is absolutely yes. Let’s have a look at implementing this for ServiceStack. Adding ServiceStack You should probably have a look at the original article first , since the SignalR part of it will be identical. Tutorial: Getting Started with SignalR (C# This tutorial shows how to use SignalR to create a real-time chat application.

Tutorial: Getting Started with SignalR (C#

You will add SignalR to an empty ASP.NET web application and create an HTML page to send and display messages. Software versions used in the tutorial. Sending stream to ServiceStack. Recently, I needed to make a ServiceStack service which can receive big files, so I wanted to use streaming to accomplish this.

Sending stream to ServiceStack

Unfortunately, there isn't much information about using streams with ServiceStack, so I decided to share my experience. We'll create a sample solution containing both Server and Client. We will create a class library containing the service itself and a Utility project. So here is the structure of our solution: let's continue with the implementation of the service. First of all, we'll need to install the ServiceStack nuget package in the ServiceStackStreaming.Service project: PM> Install-Package ServiceStack. C# - Does HttpListener work well on Mono. How To: Walkthrough Using HttpListener or Http Server unmanaged code (C++) as an SSL Simple Server - Http Client Protocol Issues (and other fun stuff I support)

There seems to be no simple end-to-end walkthrough for creating a simple HttpListener based SSL Listener that includes how to configure the computer by generating and installing a Certificate for this listener.

How To: Walkthrough Using HttpListener or Http Server unmanaged code (C++) as an SSL Simple Server - Http Client Protocol Issues (and other fun stuff I support)

Basic concepts covered: Write the listener code to listen for SSL requests Generate a self signed Certificate Configure the machine to use a Certificate Write the listener code to listen for SSL requests Here is the documentation for HttpListener: Copy the code from the above page and paste it into a new C# Console application right under the Main() function. Now from the Main function call the function you pasted in passing the prefixes you wish to listen to. The code should now compile and you can run in the debugger. The failure occurs because we have not set up a certificate for the listener to use for SSL traffic (https). Class Programmer : IEnableMuch {: Self-hosting ServiceStack serving razor'd HTML. In this walkthrough, I'll show you how to setup a self-hosting(i.e. this doesn't use ASP.NET nor ASP.NET MVC) ServiceStack that serves HTML.

class Programmer : IEnableMuch {: Self-hosting ServiceStack serving razor'd HTML

The HTML can be made dynamic through razor 21 steps 1. Start Visual Studio in Administrator mode. Open source .NET and Mono web services framework. Home · ServiceStack/ServiceStack Wiki. C# - What is the best way to run ServiceStack on Linux / Mono. ServiceStack/ServiceStack.Examples. Run ServiceStack as a daemon on Linux · ServiceStack/ServiceStack Wiki. When your web application is predominantly javascript with a REST service at the back-end there are many reasons why you might want to simply serve the static content through apache (or alternative) and run the service as a ...well... service.

Run ServiceStack as a daemon on Linux · ServiceStack/ServiceStack Wiki

Some examples are: Faster start-up timesAvoiding lengthy XML configuration filesProblems with mono ASP.NET memory leaks and random exceptions. Fortunately this is quite simple. Service example The earlier example of self hosting provides a good starting point, but needs to be modified slightly if running as a daemon. Be aware that this makes use of posix functionality and will therefore not work under Windows. Daemonising the application As it stands the project produces a console application that responds to unix signals (press ctrl-c to exit if you are running it from a terminal). Create the following at /etc/init/example.conf Ideally we would start the service when apache is ready but apache does not yet emit upstart events. . $ sudo start example. Service Stack.