Adobe P2P VideoPhone with asp.net registration
2/14/2010 11:44:00 PM
Posted by RIAlog
The Adobe p2p and Stratus are not that new. its sample application is cool and shows more than just textual p2p connection like other tutorials, but actually shows a good enough voice and image transfer.
BUT, as a .Net programmer, the registration Python code was a bit wierd to work with. Moreover, the application is literally poor in user management, so I needed a good start point to have that registration use real DB.
So, you want to use ASP.NET with Adobe Stratus VideoPhone ? here you go: ( I used Linq to SQL for this one. DB name is simply "P2P")
reg.asxh:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace P2PRegistration { ////// Summary description for $codebehindclassname$ /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class reg : IHttpHandler { public void ProcessRequest(HttpContext context) { RegistrationDBDataContext db = new RegistrationDBDataContext(); string user = context.Request.QueryString["username"]; string identity = context.Request.QueryString["identity"]; string friendsString = context.Request.QueryString["friends"]; List friends = new List(); if (friendsString != null && friendsString != "") { friends = friendsString.Split(',').ToList(); } context.Response.ContentType = "text/plain"; context.Response.Write(@""); context.Response.Write(@""); if (user != null && user != "" && identity != null && identity != "") { context.Response.Write(@" "); } public bool IsReusable { get { return false; } } } }"); try { var rUser = from p in db.registrations where (p.m_username == user) select p; if (rUser.Count() > 0) { //update rUser.First().m_username = user; rUser.First().m_identity = identity; rUser.First().m_updatetime = DateTime.Now; } else { registration newReg = new registration(); newReg.m_username = user; newReg.m_identity = identity; newReg.m_updatetime = DateTime.Now; db.registrations.InsertOnSubmit(newReg); } db.SubmitChanges(); context.Response.Write("true"); } catch { context.Response.Write("false"); } context.Response.Write(@" "); } foreach (string f in friends) { context.Response.Write(@""); context.Response.Write(@" "); } context.Response.Write(@""); context.Response.Write(context.Server.UrlEncode(f)); context.Response.Write(@" "); var rFriends = from p in db.registrations where p.m_username == f && p.m_updatetime > DateTime.Now.AddHours(-1) select p; foreach (registration r in rFriends) { string ident = r.m_identity; if (ident == null) ident = ""; context.Response.Write(@""+context.Server.UrlEncode(ident)+@" "); if (f != r.m_username) { context.Response.Write(@""+r.m_username+" "); } } context.Response.Write(@"
You will need a simple DB for that:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[registrations]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[registrations]( [m_username] [varchar](100) NOT NULL, [m_identity] [varchar](100) NULL, [m_updatetime] [datetime] NULL, CONSTRAINT [PK__registrations__7C8480AE] PRIMARY KEY CLUSTERED ( [m_username] ASC )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END
Now, just place the url of your reg.aspx in the videolab source mxml:
... // please insert your webservice URL here for exchanging private const WebServiceUrl:String = "http://[your domain here]/reg.ashx"; ...
Enjoy!
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
. Follow any responses to this post through RSS. You can leave a response, or trackback from your own site.
Subscribe to:
Post Comments (Atom)
April 20, 2010 at 12:17 PM
Thank you for your post.
Just one comment, the tags need to be in lower case instead of and so on.