This repository has been archived by the owner on Oct 19, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09d9179
commit 4c383f6
Showing
34 changed files
with
271 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Samples/SuperWebSocketWeb/Default.aspx → Samples/LiveWebChat/Default.aspx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...uperWebSocketWeb/Default.aspx.designer.cs → Samples/LiveWebChat/Default.aspx.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Samples/SuperWebSocketWeb/Global.asax → Samples/LiveWebChat/Global.asax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="SuperWebSocketWeb.Global" Language="C#" %> | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="SuperWebSocket.Samples.LiveWebChat.Global" Language="C#" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Web; | ||
using System.Web.Security; | ||
using System.Web.SessionState; | ||
using SuperSocket.Common; | ||
using SuperSocket.SocketBase; | ||
using SuperSocket.SocketBase.Command; | ||
using SuperSocket.SocketBase.Config; | ||
using SuperSocket.SocketBase.Logging; | ||
using SuperSocket.SocketEngine; | ||
using SuperSocket.SocketEngine.Configuration; | ||
using SuperWebSocket; | ||
|
||
namespace SuperWebSocket.Samples.LiveWebChat | ||
{ | ||
public class Global : System.Web.HttpApplication | ||
{ | ||
private IBootstrap m_Bootstrap; | ||
private WebSocketServer m_WebSocketServer; | ||
|
||
void Application_Start(object sender, EventArgs e) | ||
{ | ||
StartSuperWebSocketByConfig(); | ||
} | ||
|
||
void StartSuperWebSocketByConfig() | ||
{ | ||
m_Bootstrap = BootstrapFactory.CreateBootstrap(); | ||
|
||
if (!m_Bootstrap.Initialize()) | ||
return; | ||
|
||
var socketServer = m_Bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SuperWebSocket")) as WebSocketServer; | ||
|
||
socketServer.NewMessageReceived += new SessionHandler<WebSocketSession, string>(socketServer_NewMessageReceived); | ||
socketServer.NewSessionConnected += socketServer_NewSessionConnected; | ||
socketServer.SessionClosed += socketServer_SessionClosed; | ||
|
||
m_WebSocketServer = socketServer; | ||
|
||
m_Bootstrap.Start(); | ||
} | ||
|
||
void socketServer_NewMessageReceived(WebSocketSession session, string e) | ||
{ | ||
SendToAll(session.Cookies["name"] + ": " + e); | ||
} | ||
|
||
void socketServer_NewSessionConnected(WebSocketSession session) | ||
{ | ||
SendToAll("System: " + session.Cookies["name"] + " connected"); | ||
} | ||
|
||
void socketServer_SessionClosed(WebSocketSession session, CloseReason reason) | ||
{ | ||
if (reason == CloseReason.ServerShutdown) | ||
return; | ||
|
||
SendToAll("System: " + session.Cookies["name"] + " disconnected"); | ||
} | ||
|
||
void SendToAll(string message) | ||
{ | ||
foreach (var s in m_WebSocketServer.GetAllSessions()) | ||
{ | ||
s.Send(message); | ||
} | ||
} | ||
|
||
void Application_End(object sender, EventArgs e) | ||
{ | ||
if (m_Bootstrap != null) | ||
m_Bootstrap.Stop(); | ||
} | ||
|
||
void Application_Error(object sender, EventArgs e) | ||
{ | ||
// Code that runs when an unhandled error occurs | ||
|
||
} | ||
|
||
void Session_Start(object sender, EventArgs e) | ||
{ | ||
// Code that runs when a new session is started | ||
|
||
} | ||
|
||
void Session_End(object sender, EventArgs e) | ||
{ | ||
// Code that runs when a session ends. | ||
// Note: The Session_End event is raised only when the sessionstate mode | ||
// is set to InProc in the Web.config file. If session mode is set to StateServer | ||
// or SQLServer, the event is not raised. | ||
|
||
} | ||
|
||
} | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.UI; | ||
using System.Web.UI.WebControls; | ||
using System.Configuration; | ||
|
||
namespace SuperWebSocket.Samples.LiveWebChat | ||
{ | ||
public partial class LiveChat : System.Web.UI.Page | ||
{ | ||
protected void Page_Load(object sender, EventArgs e) | ||
{ | ||
var nameCookie = Request.Cookies.Get("name"); | ||
|
||
if (nameCookie == null) | ||
Response.Redirect("~/Default.aspx?returnUrl=" + Server.UrlEncode(Request.FilePath)); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...perWebSocketWeb/LiveChat.aspx.designer.cs → ...les/LiveWebChat/LiveChat.aspx.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...etWeb/LiveChatWithBridge.aspx.designer.cs → ...bChat/LiveChatWithBridge.aspx.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Push.aspx.cs" Inherits="SuperWebSocketWeb.Push" %> | ||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head runat="server"> | ||
<title></title> | ||
</head> | ||
<body> | ||
<form id="form1" runat="server"> | ||
<div> | ||
<script language="javascript" type="text/javascript"> | ||
var xmlhttp; | ||
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari | ||
xmlhttp = new XMLHttpRequest(); | ||
} | ||
else {// code for IE6, IE5 | ||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | ||
} | ||
xmlhttp.onreadystatechange = function () { | ||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | ||
alert(xmlhttp.responseText); | ||
} | ||
} | ||
xmlhttp.open("POST", "Push.aspx?Pooling=true", true); | ||
xmlhttp.send(); | ||
</script> | ||
</div> | ||
</form> | ||
</body> | ||
</html> |
Oops, something went wrong.