|
I'm thinking of writing a game in C# that have a "searching for
opponents" feature, like the internet checker included in Windows XP.
What do I need to do that? Since I'm directing searching for an opponent on the internet, so I don't think I need to have a server, do I?
Okay, but how?
|
|
|
|
|
you *could* be cheap and use the IRC protocol to make the clients go to a secluded room on a popular server, and from that point inside the room, communicate using a proprietary protocol. However, I don't think the admins of that server would smile down too kindly on you.
|
|
|
|
|
In other words, yes, you need your own server to do this. How can you search the Internet for opponenets when there are some 4 BILLION addresses to look at? You need to have some central place that each game can register itself at so you can easily contact other players. That's how all the off-the-shelf games do it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Okay, my idea is very similar to an instant messenger -- Do I
need a server for the instant messenger to work? So, if I do need
it, how do I do that? What technology should I use? SQL server?
or IRC protocol? but how to enable it?
Sorry for my stupid question........
Thanks
|
|
|
|
|
I would HIGHLY suggest picking up a book on remoting before you even attempt this. Otherwise your just wasting your time. For a game project like this, on a smaller scale, you don't have to use SQL server for anything. The server app can store all the session data it needs in memory.
The protocol is something you define. What does an IRC protocol know about your game? Nothing! So you have to write the rules of communication and what you want to communicate. That's the definition of a protocol...
You could use TCP/IP Sockets, .NET Remoting, WebServices, ... Like I said, pick up a book on these thing first. The best book is one YOU can understand, not the next guy on the board who's got 20 years of programming experience can could flip through the same book and in 20 minutes and call it "read".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm feeling so sad.......
but thank you for your reply.
|
|
|
|
|
Alex Ngai wrote:
I'm feeling so sad
Why? Because you have to read a book on the subject? Because it is more challenging than you imagined?
Your bio says your a computer science major (excuse my lack of understanding on the US education system here) but doesn't that mean you are still at university? Surely you should be used to reading books. If I've misinterpreted and it means you've recently graduated then you have to realise that learning and educating yourself will not stop... EVER!
On the area of it being more challenging that you imagined then just think about what leanring the area will make of you. Imagine how much your overall understanding will improve. Think of all the extra employment opportunities that open to you when you can demonstrate knowledge in this area.
I hope this encourages you to continue with your project because I think once you understand how these technologies work you will probably find it isn't so hard.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I'm feeling sad is because I need another computer
in order to do a multi-player feature in my game.
Since I don't have the money to buy another computer
for the server, that means I won't be able to do
what I wanted to do.
Yes, I'm still in University, and reading books is
part of my daily life. And because I'm still in
University, that means I'm poor.....err, yea!!
But thanks anyway, I think I will focus on other
aspect, and I'm going to cancel the multi-player
feature. By the way, if you know a way to avoid
the use of server, let me know.
Thanks
|
|
|
|
|
Don't be sad...read the remoteing and/or web services book(s).
In general, there's no reason why the "server" portion of the game has to reside on a physically seperate machine from your "client".
Bill
"it's all ball-bearings these days"
|
|
|
|
|
Like Bill Dean said, the server can run on the same machine as the client.
"Server" means more than just the hardware of a computer. The term more refers to the software that shares out its resources, or the resources of the machine on which it runs. But, being a Computer Science major, you already knew that, didn't you?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am having some trouble with setting a value to ComboBox.SelectedValue and then saving that value using DataBinding.
Example:
// There are five controls on a form, 1 ComboBox (comboBox), 2 TextBoxes (tbx1, tbx2) and 2 buttons (btnNew, btnSave)
DataSet dsFillCombo;
DataSet ds1;
// I fill each DataSet using separate data adapters
...
// The Combo is Bound like this
comboBox.DataSource = dsFillCombo;
comboBox.DisplayMember = "sectionIds.sectionName";
comboBox.ValueMember = "sectionIds.sectionId";
// So far, pretty basic. Now I bind the controls on the form to my other
// DataSet
tbx1.DataBinding.Add("Text", ds1, "users.fName");
tbx2.DataBinding.Add("Text", ds1, "users.lName");
comboBox.DataBinding.Add("SelectedValue", ds1, "users.sectionId");
BindingManagerBase bm = BindingContext[ds1, "users"];
// Still pretty basic, I could add more buttons to change the record
// position, and the values
// in the form controls would change with the data rows.
// Now for my issue!
// For the btnNew I want to add a new record to the dataset and set the
// comboBox to the same value that it is currently.
private void btnNew_Click(object sender, System.EventArgs e)
{
int i = Convert.ToInt32(this.comboBox.SelectedValue);
bm.AddNew();
this.comboBox.SelectedValue = sid;
}
// Now I click the Save button and...
private void btnSave_Click(object sender, System.EventArgs e)
{
bm.EndCurrentEdit();
}
As soon as I click btn_Save an Exception is thrown:
System.NoNullAllowedException: Column 'sectionId' does not allow nulls. ...
If I actually select a new value using the comboBox then the new record is saved without an issue.
Is there a way to set the SelectedValue of a ComboBox from code and have that value recongnized by DataBinding?
Thank you for any assistance.
Brett Slaski
|
|
|
|
|
Either assign DBNull.Value if the DataColumn allows nulls, or make sure it's assigned. Using a typed DataSet can help lay out the DataSet , though it's all programmatic and nothing you can do manually (just much easier using the designer, plus it adds a lot of extran functionality for you as well - especially with .NET 2.0).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It was suggested to me to use SelectedIndex instead of SelectedValue in my btnNew_Click method:
private void btnNew_Click(object sender, System.EventArgs e)
{
int i = Convert.ToInt32(this.comboBox.SelectedValue);
bm.AddNew();
this.comboBox.SelectedValue = sid;
}
>>>> Change to:
private void btnNew_Click(object sender, System.EventArgs e)
{
int i = this.comboBox.SelectedIndex;
bm.AddNew();
this.comboBox.SelectedIndex = sid;
}
Which this works great. I can preset the ComboBox to a value and it will be recognized by DataBinding, which isn't the case when you use SelectedValue. I just wonder how I would handle this if I don't know the index? If I have a langauge selector to default to the users preferred language, I know "EN" or "SP" but I don't know their index value. Is there a way to get this?
Brett Slaski
|
|
|
|
|
There's always almost an index. Even in a Hashtable (which, in itself, doesn't use indexes but buckets), you can get an index of a key or value at that time (changing the Hashtable may invalidate that if the number of buckets must be increased to handle the capacity, of course). Any IList implement defines IndexOf , which can help. That doesn't mean, of course, that it will work (you might get an NotSupportedException ), but every IList implementation I've ever worked with does define this method to do what it should.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm designing my first app in VS.NET using C#. I've created an outlook style toolbar down the side of my main form, and I want to change the content to the right of these buttons when the user clicks on the different buttons. I had it working fine with my toolbar buttons (which are custom and get deactivated every time I click on the design view) coded into Form1 but this is very cumbersome.
I want to use seperate UserControls for each of my content panels, and a seperate UserControl for my custom toolbar of buttons.
My problem is now one of referencing. I can't get my UserControl to tell Form1 to switch the visibility of my panels (change my panels).
This is how my main method gets the ball rolling:
static void Main()
{
Application.Run(new Form1());
}
So I don't know how to get ahold of an instance of my Form1 class so that my UserControls can say something like :
MyForm.SetVisiblePanel(panel_id);
Any suggestions?
also, what does the Form1_Load method do? VS seems to like to pop these methods in but they are empty.
|
|
|
|
|
You don't do anything in main. In your definition of Form1 , pass this (Form1 ) to the constructos of other controls or as properties. If those controls are children of that Form , cast the childrens' Parent properties to Form1 and access what you need to (so long as it's public or internal (public only within an assembly)).
It's all about keep references of objects assigned to variables and passing them as parameters. This is simple, straight-forward object-oriented programming.
What does Form1_Load do? If you look at your source code for Form1 , you'll see it's the event handler for the form's Load event. It was put there and is empty because you double-clicked the form at some point. VS.NET will automatically add an event handler for the default event when you double-click a control (like the Click event for a Button ). Visual Basic 6 was no different.
I recommend reading through some articles here and reading about the .NET Framework at http://msdn.microsoft.com/netframework[^]. Understanding these simple concepts is crucial to developing applications - not just coding programs.
There are also many examples of such applications that you're working on, such as A designable propertytree for VS.NET[^].
Abstraction also fits very nicely into such a model.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi every body
i want to ask:
how we can prevent the user from ending the process from the task manager?
the a second question is how we can make the service interactive with the desktop
i know that there is ServiceType calss but when i try to use it the service dos'nt interact with the desktop and here is the segment of the code which i wrote
..........
...........
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.st=System.ServiceProcess.ServiceType.InteractiveProcess;
this.serviceInstaller1.ServiceName = "Service2";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1,this.st });
..............
..............
note i install the service by setup project
with regards
|
|
|
|
|
Wail A.Salem wrote:
how we can prevent the user from ending the process from the task manager?
You can't. But you can respond to notification that a user is killing your process. Handle the Closing or Close event of your main form (the one you pass directly or indirectly to Application.Run ). If your code is not finished in a timely manner, your process will be killed. There are a few other ways as well, but I'll leave this as an exercise for you. I recommend reading through the Windows Management APIs section of the MSDN Online Library[^].
As for the second question, you have to write this to the registry yourself. So add a registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\<YourServiceName>\Type such as 288 (256 for "Interact with desktop" OR'd with 32 for the service type), or whatever is appropriate for your service type so long as you perform a bitwise OR with 256 and run it as the LocalSystem (default). If you run it as a user, then the service can only interact with that user's desktop (assuming the user has an associated desktop session and can log in locally).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've just started doing a bit of stuff with text and I can't seem to find anologs for GetTextExtentPoint32() and the like in the Graphics or Font classes. Any hints where that stuff is?
For example, I want to find the size of a string in a given font.
Matt Gerrans
|
|
|
|
|
MeasureCharacterRanges[^]
There is also a function MeasureString() which is a member of the Graphics class, it is overloaded to perform a number of different measurement types.
Hope that helps.
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
Yes, that looks like just the thing. Thanks!
Matt Gerrans
|
|
|
|
|
Hi,
How can i run an external program (some .EXE program) from my c# program, wait till this program ends, and then continue the c# program?
ideas?
|
|
|
|
|
Use the Process.WaitForExit method:
Process p = new Process();
p.StartInfo.FileName = "calc.exe";
p.Start();
p.WaitForExit();
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'v replied to mav.northwind and your comments about the "lawsuite issue".
There is no malicious intent what so ever behind the creation of this application, i am just a 4th year IT student wanting to complete my project subject. And the results gained from this application is to create user profiles and to check what are the most frequent sites visited, search engines used and most common files downloaded.
I approached you because you have been answering my questions and helping me the most on the message forums. You've directed me to use BHO's
I would really appreciate it if you could help me with creating a BHO to log url's visited by user's and to log the files that they downloaded, thats all i want to use the BHO for.
Code or site references would be very much apppreciated...
After your response to my queries, i'v been struggling for two weeks to create a BHO ...
Any help would be very much appreciated ...
From a student in need
|
|
|
|
|
In what language? C#? Not exactly the best choice, but it's possible (albeit much slower due to marshaling). If you want resources, a quick search for "BHO" on MSDN[^] would turn up the article, Browser Helper Objects: The Browser the Way You Want It[^].
If you want to do this in C#, you have to declare the IObjectWithSite interface at the very least. It would help to interop the shdocvw.dll library using tlbimp.exe.
The basic concept is that you get the interface for the IWebBrowser (QueryInterface - or casting in .NET with COM interop), get the DWebBrowserEvents2 event interface (also interop'd if you're doing this in C#), and handle any number of events, like DownloadBegin . There's a number of events you could handle, and this will fire before downloading anything. Anything you see in a browser (web page, image, stylesheet, or other file to download) is actually downloaded to your machine. Several events will alert you when a download begins.
Start with the article, and again I recommend you do not use C#. Even though it JIT compiles to native code, there's still a lot of marshaling required once loaded and JIT compiled. Go native - it's much easier and you won't have to be declaring interfaces, structs, consts, and P/Invoking functions as needed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|